From ac98964910369dd9821316a68f5477bd0d8e4ced Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Fri, 25 Oct 2024 02:30:34 +0200 Subject: [PATCH] We should only use _url when changing the host, otherwise _path is better (#53445) --- .../app/controllers/concerns/authentication.rb.tt | 2 +- .../templates/app/controllers/passwords_controller.rb.tt | 8 ++++---- .../templates/app/controllers/sessions_controller.rb.tt | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/railties/lib/rails/generators/rails/authentication/templates/app/controllers/concerns/authentication.rb.tt b/railties/lib/rails/generators/rails/authentication/templates/app/controllers/concerns/authentication.rb.tt index d216ce52ddc01..771b21dff6efb 100644 --- a/railties/lib/rails/generators/rails/authentication/templates/app/controllers/concerns/authentication.rb.tt +++ b/railties/lib/rails/generators/rails/authentication/templates/app/controllers/concerns/authentication.rb.tt @@ -33,7 +33,7 @@ module Authentication def request_authentication session[:return_to_after_authenticating] = request.url - redirect_to new_session_url + redirect_to new_session_path end def after_authentication_url diff --git a/railties/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt b/railties/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt index 9c6e2b3818967..0c4b4a89332b2 100644 --- a/railties/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt +++ b/railties/lib/rails/generators/rails/authentication/templates/app/controllers/passwords_controller.rb.tt @@ -10,7 +10,7 @@ class PasswordsController < ApplicationController PasswordsMailer.reset(user).deliver_later end - redirect_to new_session_url, notice: "Password reset instructions sent (if user with that email address exists)." + redirect_to new_session_path, notice: "Password reset instructions sent (if user with that email address exists)." end def edit @@ -18,9 +18,9 @@ class PasswordsController < ApplicationController def update if @user.update(params.permit(:password, :password_confirmation)) - redirect_to new_session_url, notice: "Password has been reset." + redirect_to new_session_path, notice: "Password has been reset." else - redirect_to edit_password_url(params[:token]), alert: "Passwords did not match." + redirect_to edit_password_path(params[:token]), alert: "Passwords did not match." end end @@ -28,6 +28,6 @@ class PasswordsController < ApplicationController def set_user_by_token @user = User.find_by_password_reset_token!(params[:token]) rescue ActiveSupport::MessageVerifier::InvalidSignature - redirect_to new_password_url, alert: "Password reset link is invalid or has expired." + redirect_to new_password_path, alert: "Password reset link is invalid or has expired." end end diff --git a/railties/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt b/railties/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt index b50f0b23e0596..9785c923c06a5 100644 --- a/railties/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt +++ b/railties/lib/rails/generators/rails/authentication/templates/app/controllers/sessions_controller.rb.tt @@ -10,12 +10,12 @@ class SessionsController < ApplicationController start_new_session_for user redirect_to after_authentication_url else - redirect_to new_session_url, alert: "Try another email address or password." + redirect_to new_session_path, alert: "Try another email address or password." end end def destroy terminate_session - redirect_to new_session_url + redirect_to new_session_path end end