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:
authorAlex Lossent <alexandre.lossent@cern.ch>2015-08-12 18:20:01 +0300
committerAlex Lossent <alexandre.lossent@cern.ch>2015-08-12 18:31:35 +0300
commitfb6e8008c4010aa5445b129e5b18e379a0ef487e (patch)
treeb02a83c7bfc51bbeb3307ce9a10659044dae4313 /app/controllers/sessions_controller.rb
parentcd579cb2ff45f3fc1513bb6ea74b53a2229276ae (diff)
Fix redirection after sign in when using auto_sign_in_with_provider
Logic for redirect path moved to a filter.
Diffstat (limited to 'app/controllers/sessions_controller.rb')
-rw-r--r--app/controllers/sessions_controller.rb39
1 files changed, 21 insertions, 18 deletions
diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb
index 796cbe4c58c..8389f07a3bd 100644
--- a/app/controllers/sessions_controller.rb
+++ b/app/controllers/sessions_controller.rb
@@ -2,27 +2,10 @@ class SessionsController < Devise::SessionsController
include AuthenticatesWithTwoFactor
prepend_before_action :authenticate_with_two_factor, only: [:create]
+ prepend_before_action :store_redirect_path, only: [:new]
before_action :auto_sign_in_with_provider, only: [:new]
def new
- redirect_path =
- if request.referer.present? && (params['redirect_to_referer'] == 'yes')
- referer_uri = URI(request.referer)
- if referer_uri.host == Gitlab.config.gitlab.host
- referer_uri.path
- else
- request.fullpath
- end
- else
- request.fullpath
- end
-
- # Prevent a 'you are already signed in' message directly after signing:
- # we should never redirect to '/users/sign_in' after signing in successfully.
- unless redirect_path == new_user_session_path
- store_location_for(:redirect, redirect_path)
- end
-
if Gitlab.config.ldap.enabled
@ldap_servers = Gitlab::LDAP::Config.servers
end
@@ -55,6 +38,26 @@ class SessionsController < Devise::SessionsController
User.find(session[:otp_user_id])
end
end
+
+ def store_redirect_path
+ redirect_path =
+ if request.referer.present? && (params['redirect_to_referer'] == 'yes')
+ referer_uri = URI(request.referer)
+ if referer_uri.host == Gitlab.config.gitlab.host
+ referer_uri.path
+ else
+ request.fullpath
+ end
+ else
+ request.fullpath
+ end
+
+ # Prevent a 'you are already signed in' message directly after signing:
+ # we should never redirect to '/users/sign_in' after signing in successfully.
+ unless redirect_path == new_user_session_path
+ store_location_for(:redirect, redirect_path)
+ end
+ end
def authenticate_with_two_factor
user = self.resource = find_user