diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-06-30 17:00:30 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-06-30 17:00:30 +0300 |
commit | f5c95598140db0881352c45e22904477bf820c46 (patch) | |
tree | 69dbdf339564cdbb0bf6c8da345df5434c0a36e3 | |
parent | f21d79251db29a31083fc389662177fc50eaac9e (diff) | |
download | gitlab-ci-f5c95598140db0881352c45e22904477bf820c46.tar.gz |
Redirect back after authorization
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/user_sessions_controller.rb | 5 | ||||
-rw-r--r-- | app/views/user_sessions/new.html.haml | 2 |
3 files changed, 5 insertions, 3 deletions
@@ -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' ) |