Skip to content
This repository has been archived by the owner on May 12, 2018. It is now read-only.

Commit

Permalink
Merge branch 'redirect_back_after_auth' into 'master'
Browse files Browse the repository at this point in the history
Redirect back after authorization

https://dev.gitlab.org/gitlab/gitlab-ci/issues/287

See merge request !182
  • Loading branch information
vsizov committed Jun 30, 2015
2 parents f21d792 + cb1d33e commit 762ffa8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions app/controllers/user_sessions_controller.rb
Expand Up @@ -10,7 +10,8 @@ def new

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

Expand All @@ -21,7 +22,7 @@ def callback
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
Expand Down
2 changes: 1 addition & 1 deletion app/views/user_sessions/new.html.haml
Expand Up @@ -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' )

0 comments on commit 762ffa8

Please sign in to comment.