diff --git a/app/controllers/devise/registrations_controller.rb b/app/controllers/devise/registrations_controller.rb index 01926bbc..53b375c9 100644 --- a/app/controllers/devise/registrations_controller.rb +++ b/app/controllers/devise/registrations_controller.rb @@ -1,11 +1,11 @@ class Devise::RegistrationsController < DeviseController prepend_before_action :require_no_authentication, only: [:new, :create, :cancel] prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy] + prepend_before_action :set_minimum_password_length, only: [:new, :edit] # GET /resource/sign_up def new build_resource({}) - set_minimum_password_length yield resource if block_given? respond_with self.resource end diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3ea40f01..1e66f3d7 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -15,6 +15,10 @@
<%= f.label :password %> (leave blank if you don't want to change it)
<%= f.password_field :password, autocomplete: "off" %> + <% if @minimum_password_length %> +
+ <%= @minimum_password_length %> characters minimum + <% end %>
diff --git a/test/integration/registerable_test.rb b/test/integration/registerable_test.rb index 9417a177..4fa361b7 100644 --- a/test/integration/registerable_test.rb +++ b/test/integration/registerable_test.rb @@ -219,6 +219,12 @@ class RegistrationTest < Devise::IntegrationTest assert_contain "Password confirmation doesn't match Password" refute User.to_adapter.find_first.valid_password?('pas123') end + + test 'a signed in user should see a warning about minimum password length' do + sign_in_as_user + get edit_user_registration_path + assert_contain 'characters minimum' + end test 'a signed in user should be able to cancel their account' do sign_in_as_user