From f7927e694e65da7a0f4d82ae2f90e10b3c331566 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Wed, 8 Feb 2023 12:03:37 +0000 Subject: [PATCH] feat: correct routing and persist params --- app/controllers/auth/passwords_controller.rb | 5 +++-- app/views/devise/passwords/reset_password.html.erb | 8 +++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb index e0dda4e02..c76ebaf6a 100644 --- a/app/controllers/auth/passwords_controller.rb +++ b/app/controllers/auth/passwords_controller.rb @@ -46,8 +46,9 @@ class Auth::PasswordsController < Devise::PasswordsController end respond_with resource, location: after_resetting_password_path_for(resource) else - set_minimum_password_length - respond_with resource, status: :unprocessable_entity + @minimum_password_length = Devise.password_length.min + @confirmation = resource_params["confirmation"] + render "devise/passwords/reset_password", status: :unprocessable_entity end end diff --git a/app/views/devise/passwords/reset_password.html.erb b/app/views/devise/passwords/reset_password.html.erb index f38e25809..2e0da0e66 100644 --- a/app/views/devise/passwords/reset_password.html.erb +++ b/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 :before_content do %> - <%= govuk_back_link(href: :back) %> -<% end %> +<% content_for :title, @confirmation.present? ? I18n.t("user.create_password") : I18n.t("user.reset_password") %> <%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> <%= f.hidden_field :reset_password_token %> @@ -22,6 +18,8 @@ <%= f.govuk_password_field :password_confirmation, label: { text: "Confirm new password" } %> + <%= f.hidden_field :confirmation, value: @confirmation %> + <%= f.govuk_submit "Update" %>