Browse Source

feat: add min password length

CLDC-1963-fix-reset-password-bugs
natdeanlewissoftwire 2 years ago
parent
commit
033950f436
  1. 2
      app/controllers/auth/passwords_controller.rb
  2. 2
      app/views/devise/passwords/edit.html.erb
  3. 2
      app/views/devise/passwords/reset_password.html.erb

2
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) self.resource = resource_class.send_reset_password_instructions(resource_params)
yield resource if block_given? yield resource if block_given?
@minimum_password_length = Devise.password_length.min
respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name)) respond_with({}, location: after_sending_reset_password_instructions_path_for(resource_name))
end end
def edit def edit
super super
@minimum_password_length = Devise.password_length.min
@confirmation = params["confirmation"] @confirmation = params["confirmation"]
render "devise/passwords/reset_password" render "devise/passwords/reset_password"
end end

2
app/views/devise/passwords/edit.html.erb

@ -15,7 +15,7 @@
<%= f.govuk_password_field :password, <%= f.govuk_password_field :password,
label: { text: "New 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" %> autocomplete: "new-password" %>
<%= f.govuk_password_field :password_confirmation, <%= f.govuk_password_field :password_confirmation,

2
app/views/devise/passwords/reset_password.html.erb

@ -16,7 +16,7 @@
<%= f.govuk_password_field :password, <%= f.govuk_password_field :password,
label: { text: "New 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" %> autocomplete: "new-password" %>
<%= f.govuk_password_field :password_confirmation, <%= f.govuk_password_field :password_confirmation,

Loading…
Cancel
Save