demarches-normaliennes/app/controllers/users/passwords_controller.rb

63 lines
1.3 KiB
Ruby
Raw Normal View History

2015-09-23 10:02:01 +02:00
class Users::PasswordsController < Devise::PasswordsController
include DevisePopulatedResource
after_action :try_to_authenticate_instructeur, only: [:update]
2018-10-01 14:26:45 +02:00
after_action :try_to_authenticate_administrateur, only: [:update]
2015-09-23 10:02:01 +02:00
# GET /resource/password/new
# def new
# super
# end
# POST /resource/password
# def create
# super
# end
2015-09-23 10:02:01 +02:00
# GET /resource/password/edit?reset_password_token=abcdef
# def edit
# super
# end
# PUT /resource/password
# def update
# # params[:user][:password_confirmation] = params[:user][:password]
2015-09-23 10:02:01 +02:00
# super
# end
def reset_link_sent
@email = params[:email]
end
protected
2015-09-23 10:02:01 +02:00
# def after_resetting_password_path_for(resource)
# super(resource)
# end
def after_sending_reset_password_instructions_path_for(resource_name)
flash.discard(:notice)
users_password_reset_link_sent_path(email: resource.email)
end
def try_to_authenticate_instructeur
if user_signed_in?
instructeur = Instructeur.by_email(current_user.email)
2018-10-01 13:24:37 +02:00
if instructeur
2019-08-07 11:15:16 +02:00
sign_in(instructeur.user)
2018-10-01 13:24:37 +02:00
end
end
end
def try_to_authenticate_administrateur
if user_signed_in?
administrateur = Administrateur.by_email(current_user.email)
2018-10-01 13:24:37 +02:00
if administrateur
2019-08-09 10:46:39 +02:00
sign_in(administrateur.user)
2018-10-01 13:24:37 +02:00
end
end
end
2015-09-23 10:02:01 +02:00
end