2015-09-23 10:02:01 +02:00
|
|
|
class Users::PasswordsController < Devise::PasswordsController
|
2016-10-13 18:26:08 +02:00
|
|
|
after_action :try_to_authenticate_gestionnaire, only: %i(update)
|
2016-12-07 17:35:45 +01:00
|
|
|
after_action :try_to_authenticate_administrateur, only: %i(update)
|
2016-10-13 18:26:08 +02:00
|
|
|
|
2015-09-23 10:02:01 +02:00
|
|
|
# GET /resource/password/new
|
|
|
|
# def new
|
|
|
|
# super
|
|
|
|
# end
|
|
|
|
|
|
|
|
# POST /resource/password
|
|
|
|
# def create
|
|
|
|
# super
|
|
|
|
# end
|
|
|
|
|
|
|
|
# GET /resource/password/edit?reset_password_token=abcdef
|
|
|
|
# def edit
|
|
|
|
# super
|
|
|
|
# end
|
|
|
|
|
|
|
|
# PUT /resource/password
|
|
|
|
# def update
|
|
|
|
# super
|
|
|
|
# end
|
|
|
|
|
|
|
|
# protected
|
|
|
|
|
|
|
|
# def after_resetting_password_path_for(resource)
|
|
|
|
# super(resource)
|
|
|
|
# end
|
|
|
|
|
|
|
|
# The path used after sending reset password instructions
|
|
|
|
# def after_sending_reset_password_instructions_path_for(resource_name)
|
|
|
|
# super(resource_name)
|
|
|
|
# end
|
2016-10-13 18:26:08 +02:00
|
|
|
|
|
|
|
def try_to_authenticate_gestionnaire
|
|
|
|
if user_signed_in?
|
|
|
|
gestionnaire = Gestionnaire.find_by(email: current_user.email)
|
2018-10-01 13:24:37 +02:00
|
|
|
|
|
|
|
if gestionnaire
|
|
|
|
sign_in gestionnaire
|
|
|
|
end
|
2016-10-13 18:26:08 +02:00
|
|
|
end
|
|
|
|
end
|
2016-12-07 17:35:45 +01:00
|
|
|
|
|
|
|
def try_to_authenticate_administrateur
|
|
|
|
if user_signed_in?
|
|
|
|
administrateur = Administrateur.find_by(email: current_user.email)
|
2018-10-01 13:24:37 +02:00
|
|
|
|
|
|
|
if administrateur
|
|
|
|
sign_in administrateur
|
|
|
|
end
|
2016-12-07 17:35:45 +01:00
|
|
|
end
|
|
|
|
end
|
2015-09-23 10:02:01 +02:00
|
|
|
end
|