Update and test password recovery forms

This commit is contained in:
2023-04-19 19:29:12 +02:00
parent 894c21f322
commit 7dabbd3036
7 changed files with 43 additions and 32 deletions

View File

@@ -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

View File

@@ -1,25 +1,13 @@
<h2>Change your password</h2>
<%= 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 %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em><br />
<% end %>
<%= f.password_field :password, autofocus: true, autocomplete: "new-password" %>
</div>
<%= f.hidden_field :reset_password_token, label: false %>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "new-password" %>
</div>
<%= 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" %>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<%= f.submit t('.update_password') %>
<% end %>
<%= render "users/shared/links" %>

View File

@@ -1,16 +1,7 @@
<h2>Forgot your password?</h2>
<%= 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 %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
</div>
<%= f.email_field :email, required: true, size: 30, autofocus: true, autocomplete: "email" %>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<%= f.submit t(:recover_password) %>
<% end %>
<%= render "users/shared/links" %>

View File

@@ -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" %>

View File

@@ -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" %>