super_admin: check password complexity client side

This commit is contained in:
Christophe Robillard 2020-11-17 16:20:27 +01:00 committed by simon lehericey
parent 90d7ee872e
commit 94b3ec942b
4 changed files with 32 additions and 4 deletions

View file

@ -3,4 +3,17 @@ class SuperAdmins::PasswordsController < Devise::PasswordsController
super
self.resource.disable_otp!
end
def test_strength
@score, @words, @length = ZxcvbnService.new(password_params[:password]).complexity
@min_length = PASSWORD_MIN_LENGTH
@min_complexity = PASSWORD_COMPLEXITY_FOR_ADMIN
render 'shared/password/test_strength'
end
private
def password_params
params.require(:super_admin).permit(:password)
end
end