diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index bd4b119cf..17e51c522 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -24,11 +24,13 @@ class Auth::PasswordsController < Devise::PasswordsController def edit super + minimum_password_length @confirmation = params["confirmation"] render "devise/passwords/reset_password" end def update + minimum_password_length self.resource = resource_class.reset_password_by_token(resource_params) yield resource if block_given? @@ -51,6 +53,10 @@ class Auth::PasswordsController < Devise::PasswordsController protected + def minimum_password_length + @minimum_password_length ||= Devise.password_length.min + end + def set_2fa_required return unless resource.respond_to?(:need_two_factor_authentication?) && resource.need_two_factor_authentication?(request) diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb index 94ef6f44c..34137a0d6 100644 --- a/app/views/devise/passwords/edit.html.erb +++ b/app/views/devise/passwords/edit.html.erb @@ -15,7 +15,7 @@ <%= f.govuk_password_field :password, label: { text: "New password" }, - hint: @minimum_password_length ? { text: "Your password must be at least #{@minimum_password_length} characters and hard to guess." } : nil, + hint: { text: "Your password must be at least #{@minimum_password_length} characters and hard to guess." }, autocomplete: "new-password" %> <%= f.govuk_password_field :password_confirmation, diff --git a/app/views/devise/passwords/reset_password.html.erb b/app/views/devise/passwords/reset_password.html.erb index 26ee6f590..f38e25809 100644 --- a/app/views/devise/passwords/reset_password.html.erb +++ b/app/views/devise/passwords/reset_password.html.erb @@ -16,7 +16,7 @@ <%= f.govuk_password_field :password, label: { text: "New password" }, - hint: @minimum_password_length ? { text: "Your password must be at least #{@minimum_password_length} characters and hard to guess." } : nil, + hint: { text: "Your password must be at least #{@minimum_password_length} characters and hard to guess." }, autocomplete: "new-password" %> <%= f.govuk_password_field :password_confirmation,