#3928 different pwd edit page for administrators

This commit is contained in:
maatinito 2019-06-19 12:34:08 -10:00 committed by Pierre de La Morinerie
parent 3bf32b6d43
commit 220b38ad2a

View file

@ -8,9 +8,19 @@ class Users::PasswordsController < Devise::PasswordsController
# end
# POST /resource/password
# def create
# super
# end
def create
# Check the credentials associated to the mail to generate a correct reset link
email = params[:user][:email]
if Administrateur.find_by(email: email)
@devise_mapping = Devise.mappings[:administrateur]
params[:administrateur] = params[:user]
# uncomment to check password complexity for Gestionnaire
# elsif Gestionnaire.find_by(email: email)
# @devise_mapping = Devise.mappings[:gestionnaire]
# params[:gestionnaire] = params[:user]
end
super
end
# GET /resource/password/edit?reset_password_token=abcdef
# def edit
@ -19,6 +29,7 @@ class Users::PasswordsController < Devise::PasswordsController
# PUT /resource/password
# def update
# # params[:user][:password_confirmation] = params[:user][:password]
# super
# end
@ -52,4 +63,15 @@ class Users::PasswordsController < Devise::PasswordsController
end
end
end
def test_strength
@score, @words, @length = ZxcvbnService.new(password_params[:password]).complexity
@min_length = PASSWORD_MIN_LENGTH
@min_complexity = PASSWORD_COMPLEXITY_FOR_USER
render 'shared/password/test_strength'
end
def password_params
params.require(:user).permit(:reset_password_token, :password)
end
end