Merge pull request #3372 from Katee/show-min-password-length-on-edit-password
Show minimum password length on edit password
This commit is contained in:
commit
5badce5e8e
|
@ -23,6 +23,7 @@ class Devise::PasswordsController < DeviseController
|
|||
# GET /resource/password/edit?reset_password_token=abcdef
|
||||
def edit
|
||||
self.resource = resource_class.new
|
||||
set_minimum_password_length
|
||||
resource.reset_password_token = params[:reset_password_token]
|
||||
end
|
||||
|
||||
|
|
|
@ -5,10 +5,7 @@ class Devise::RegistrationsController < DeviseController
|
|||
# GET /resource/sign_up
|
||||
def new
|
||||
build_resource({})
|
||||
@validatable = devise_mapping.validatable?
|
||||
if @validatable
|
||||
@minimum_password_length = resource_class.password_length.min
|
||||
end
|
||||
set_minimum_password_length
|
||||
yield resource if block_given?
|
||||
respond_with self.resource
|
||||
end
|
||||
|
@ -31,10 +28,7 @@ class Devise::RegistrationsController < DeviseController
|
|||
end
|
||||
else
|
||||
clean_up_passwords resource
|
||||
@validatable = devise_mapping.validatable?
|
||||
if @validatable
|
||||
@minimum_password_length = resource_class.password_length.min
|
||||
end
|
||||
set_minimum_password_length
|
||||
respond_with resource
|
||||
end
|
||||
end
|
||||
|
|
|
@ -154,6 +154,14 @@ MESSAGE
|
|||
end
|
||||
end
|
||||
|
||||
# Sets minimum password length to show to user
|
||||
def set_minimum_password_length
|
||||
@validatable = devise_mapping.validatable?
|
||||
if @validatable
|
||||
@minimum_password_length = resource_class.password_length.min
|
||||
end
|
||||
end
|
||||
|
||||
def devise_i18n_options(options)
|
||||
options
|
||||
end
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
|
||||
<div class="field">
|
||||
<%= f.label :password, "New password" %><br />
|
||||
<% if @validatable %>
|
||||
<em>(<%= @minimum_password_length %> characters minimum)</em>
|
||||
<% end %><br />
|
||||
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<%= f.full_error :reset_password_token %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :password, label: "New password", required: true, autofocus: true %>
|
||||
<%= f.input :password, label: "New password", required: true, autofocus: true, hint: ("#{@minimum_password_length} characters minimum" if @validatable) %>
|
||||
<%= f.input :password_confirmation, label: "Confirm your new password", required: true %>
|
||||
</div>
|
||||
|
||||
|
|
Loading…
Reference in New Issue