diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 345632b..1dacef5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -12,6 +12,7 @@ module ApplicationHelper end def label_for(method, options = {}) + return "" if (options[:label] == false) text = options.delete(:label) text ||= @object.class.human_attribute_name(method).capitalize diff --git a/app/views/users/passwords/edit.html.erb b/app/views/users/passwords/edit.html.erb index 863ffbb..70abb9e 100644 --- a/app/views/users/passwords/edit.html.erb +++ b/app/views/users/passwords/edit.html.erb @@ -1,25 +1,13 @@ -

Change your password

- -<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> +<%= tabular_form_for resource, url: user_password_path, html: { method: :put } do |f| %> <%= render "users/shared/error_messages", resource: resource %> - <%= f.hidden_field :reset_password_token %> -
- <%= f.label :password, "New password" %>
- <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum)
- <% end %> - <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %> -
+ <%= f.hidden_field :reset_password_token, label: false %> -
- <%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> -
+ <%= f.password_field :password, label: t('.new_password'), + required: true, size: 30, autofocus: true, autocomplete: "new-password", + hint: ("(#{@minimum_password_length} characters minimum)" if @minimum_password_length) %> + <%= f.password_field :password_confirmation, label: t('.password_confirmation'), + required: true, size: 30, autocomplete: "new-password" %> -
- <%= f.submit "Change my password" %> -
+ <%= f.submit t('.update_password') %> <% end %> - -<%= render "users/shared/links" %> diff --git a/app/views/users/passwords/new.html.erb b/app/views/users/passwords/new.html.erb index 3b30b06..e9dec5d 100644 --- a/app/views/users/passwords/new.html.erb +++ b/app/views/users/passwords/new.html.erb @@ -1,16 +1,7 @@ -

Forgot your password?

- -<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> +<%= tabular_form_for resource, url: user_password_path, html: { method: :post } do |f| %> <%= render "users/shared/error_messages", resource: resource %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> -
+ <%= f.email_field :email, required: true, size: 30, autofocus: true, autocomplete: "email" %> -
- <%= f.submit "Send me reset password instructions" %> -
+ <%= f.submit t(:recover_password) %> <% end %> - -<%= render "users/shared/links" %> diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index 1936da6..256c84b 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -10,6 +10,7 @@ <%= f.submit t(:register) %> <% end %> + <%= content_tag :p, t(:or), style: "text-align: center;" %> <%= image_link_to t(:resend_confirmation), "email-sync-outline", new_user_confirmation_path, class: "centered" %> diff --git a/app/views/users/sessions/new.html.erb b/app/views/users/sessions/new.html.erb index ca84aa5..4213a79 100644 --- a/app/views/users/sessions/new.html.erb +++ b/app/views/users/sessions/new.html.erb @@ -8,5 +8,6 @@ <%= f.submit t(:sign_in) %> <% end %> + <%= content_tag :p, t(:or), style: "text-align: center;" %> <%= image_link_to t(:recover_password), "lock-reset", new_user_password_path, class: "centered" %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 883c165..59b32c3 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -5,6 +5,11 @@ en: email: e-mail password: password users: + passwords: + edit: + new_password: New password + password_confirmation: Retype new password + update_password: Update password registrations: new: password_confirmation: Retype password diff --git a/test/system/users_test.rb b/test/system/users_test.rb index 8ab29d5..79f2ff6 100644 --- a/test/system/users_test.rb +++ b/test/system/users_test.rb @@ -49,4 +49,28 @@ class UsersTest < ApplicationSystemTestCase assert_text t('devise.confirmations.confirmed') assert User.last.confirmed? end + + test "recover password" do + visit new_user_session_url + click_link t(:recover_password) + + fill_in User.human_attribute_name(:email).capitalize, with: users.sample.email + assert_emails 1 do + click_on t(:recover_password) + end + assert_current_path new_user_session_path + assert_text t('devise.passwords.send_instructions') + + with_last_email do |mail| + visit Capybara.string(mail.body.to_s).find_link("Change my password")[:href] + end + new_password = random_password + fill_in t('users.passwords.edit.new_password'), with: new_password + fill_in t('users.passwords.edit.password_confirmation'), with: new_password + assert_emails 1 do + click_on t('users.passwords.edit.update_password') + end + assert_no_current_path user_password_path + assert_text t('devise.passwords.updated') + end end