Browse Source

feat: correct routing and persist params

CLDC-1963-fix-reset-password-bugs
natdeanlewissoftwire 2 years ago
parent
commit
f7927e694e
  1. 5
      app/controllers/auth/passwords_controller.rb
  2. 8
      app/views/devise/passwords/reset_password.html.erb

5
app/controllers/auth/passwords_controller.rb

@ -46,8 +46,9 @@ class Auth::PasswordsController < Devise::PasswordsController
end end
respond_with resource, location: after_resetting_password_path_for(resource) respond_with resource, location: after_resetting_password_path_for(resource)
else else
set_minimum_password_length @minimum_password_length = Devise.password_length.min
respond_with resource, status: :unprocessable_entity @confirmation = resource_params["confirmation"]
render "devise/passwords/reset_password", status: :unprocessable_entity
end end
end end

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

@ -1,8 +1,4 @@
<% content_for :title, @confirmation ? I18n.t("user.create_password") : I18n.t("user.reset_password") %> <% content_for :title, @confirmation.present? ? I18n.t("user.create_password") : I18n.t("user.reset_password") %>
<% content_for :before_content do %>
<%= govuk_back_link(href: :back) %>
<% end %>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= f.hidden_field :reset_password_token %> <%= f.hidden_field :reset_password_token %>
@ -22,6 +18,8 @@
<%= f.govuk_password_field :password_confirmation, <%= f.govuk_password_field :password_confirmation,
label: { text: "Confirm new password" } %> label: { text: "Confirm new password" } %>
<%= f.hidden_field :confirmation, value: @confirmation %>
<%= f.govuk_submit "Update" %> <%= f.govuk_submit "Update" %>
</div> </div>
</div> </div>

Loading…
Cancel
Save