From d258ec8e3ba7eec75d4da645444d03975e8dd62c Mon Sep 17 00:00:00 2001
From: CSDUMMI <31551856+CSDUMMI@users.noreply.github.com>
Date: Mon, 13 Mar 2023 00:06:27 +0100
Subject: [PATCH] Prefer the stored location as after_sign_in_path in Omniauth
 Callback Controller (#24073)

---
 app/controllers/auth/omniauth_callbacks_controller.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/app/controllers/auth/omniauth_callbacks_controller.rb b/app/controllers/auth/omniauth_callbacks_controller.rb
index 3d7962de5..9e0fb942a 100644
--- a/app/controllers/auth/omniauth_callbacks_controller.rb
+++ b/app/controllers/auth/omniauth_callbacks_controller.rb
@@ -33,7 +33,7 @@ class Auth::OmniauthCallbacksController < Devise::OmniauthCallbacksController
 
   def after_sign_in_path_for(resource)
     if resource.email_present?
-      root_path
+      stored_location_for(resource) || root_path
     else
       auth_setup_path(missing_email: '1')
     end