summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-06-30 17:00:30 +0300
committerValery Sizov <vsv2711@gmail.com>2015-06-30 17:00:30 +0300
commitf5c95598140db0881352c45e22904477bf820c46 (patch)
tree69dbdf339564cdbb0bf6c8da345df5434c0a36e3
parentf21d79251db29a31083fc389662177fc50eaac9e (diff)
downloadgitlab-ci-f5c95598140db0881352c45e22904477bf820c46.tar.gz
Redirect back after authorization
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/user_sessions_controller.rb5
-rw-r--r--app/views/user_sessions/new.html.haml2
3 files changed, 5 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 49ab594..e3f48c3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@ v7.13.0
- Implemented "rake env:info". Rake task to receive system information
- Fix coverage calculation on commit page
- Enhance YAML validation
+ - Redirect back after authorization
v7.12.1
- Runner without tag should pick builds without tag only
diff --git a/app/controllers/user_sessions_controller.rb b/app/controllers/user_sessions_controller.rb
index 5700615..7aa1132 100644
--- a/app/controllers/user_sessions_controller.rb
+++ b/app/controllers/user_sessions_controller.rb
@@ -10,7 +10,8 @@ class UserSessionsController < ApplicationController
def auth
redirect_to client.auth_code.authorize_url({
- redirect_uri: callback_user_sessions_url
+ redirect_uri: callback_user_sessions_url,
+ state: params[:return_to]
})
end
@@ -21,7 +22,7 @@ class UserSessionsController < ApplicationController
user = @user_session.authenticate(access_token: token)
if user && sign_in(user)
- redirect_to root_path
+ redirect_to (params[:state] || root_path)
else
@error = 'Invalid credentials'
render :new
diff --git a/app/views/user_sessions/new.html.haml b/app/views/user_sessions/new.html.haml
index 5f33e09..b457e93 100644
--- a/app/views/user_sessions/new.html.haml
+++ b/app/views/user_sessions/new.html.haml
@@ -4,5 +4,5 @@
Make sure you have account on GitLab server
= link_to GitlabCi.config.gitlab_server.url, GitlabCi.config.gitlab_server.url, no_turbolink
%hr
- = link_to "Login with GitLab", auth_user_sessions_path, no_turbolink.merge( class: 'btn btn-login btn-success' )
+ = link_to "Login with GitLab", auth_user_sessions_path(return_to: params[:return_to]), no_turbolink.merge( class: 'btn btn-login btn-success' )