From 033950f436f81455cf25cc584611da2b302d0127 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 8 Feb 2023 09:28:02 +0000 Subject: [PATCH] feat: add min password length --- app/controllers/auth/passwords_controller.rb | 2 ++ app/views/devise/passwords/edit.html.erb | 2 +- app/views/devise/passwords/reset_password.html.erb | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index bd4b119cf..e0dda4e02 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -19,11 +19,13 @@ class Auth::PasswordsController < Devise::PasswordsController self.resource = resource_class.send_reset_password_instructions(resource_params) yield resource if block_given? + @minimum_password_length = Devise.password_length.min respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name)) end def edit super + @minimum_password_length = Devise.password_length.min @confirmation = params["confirmation"] render "devise/passwords/reset_password" end 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,