Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Escue <scott.escue@gmail.com>2018-05-22 23:04:19 +0300
committerMike Greiling <mike@pixelcog.com>2019-01-10 09:00:38 +0300
commit6540a9468a8bce3f496423179db1862cfb9f5c8c (patch)
tree28a3c968eeaf8c21377fc80cf0b16c2700b76689 /app/controllers/omniauth_callbacks_controller.rb
parent4a6c7661edae664a7f6366201d017e24d8f42026 (diff)
Preserve URL fragment across sign-in and sign-up redirects
If window.location contains a URL fragment, append the fragment to all sign-in forms, the sign-up form, and all button based providers.
Diffstat (limited to 'app/controllers/omniauth_callbacks_controller.rb')
-rw-r--r--app/controllers/omniauth_callbacks_controller.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb
index 30be50d4595..12f11976439 100644
--- a/app/controllers/omniauth_callbacks_controller.rb
+++ b/app/controllers/omniauth_callbacks_controller.rb
@@ -75,6 +75,12 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
private
def omniauth_flow(auth_module, identity_linker: nil)
+ omniauth_params = request.env['omniauth.params']
+
+ if omniauth_params.present? && omniauth_params['redirect_fragment'].present?
+ store_redirect_fragment(omniauth_params['redirect_fragment'])
+ end
+
if current_user
log_audit_event(current_user, with: oauth['provider'])
@@ -189,4 +195,14 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
request_params = request.env['omniauth.params']
(request_params['remember_me'] == '1') if request_params.present?
end
+
+ def store_redirect_fragment(redirect_fragment)
+ key = stored_location_key_for(:user)
+ location = session[key]
+ unless location.to_s.strip.empty?
+ uri = URI.parse(location)
+ uri.fragment = redirect_fragment
+ store_location_for(:user, uri.to_s)
+ end
+ end
end