Sign associated user/gestionnaire in after password change

This commit is contained in:
Julien Portalier 2016-10-13 18:26:08 +02:00 committed by Xavier J
parent c2068d055d
commit 45e14d7a43
4 changed files with 76 additions and 0 deletions

View file

@ -1,4 +1,6 @@
class Users::PasswordsController < Devise::PasswordsController
after_action :try_to_authenticate_gestionnaire, only: %i(update)
# GET /resource/password/new
# def new
# super
@ -29,4 +31,11 @@ class Users::PasswordsController < Devise::PasswordsController
# def after_sending_reset_password_instructions_path_for(resource_name)
# super(resource_name)
# end
def try_to_authenticate_gestionnaire
if user_signed_in?
gestionnaire = Gestionnaire.find_by(email: current_user.email)
sign_in gestionnaire if gestionnaire
end
end
end