diff options
author | Marin Jankovski <marin@gitlab.com> | 2014-07-11 12:24:11 +0200 |
---|---|---|
committer | Marin Jankovski <marin@gitlab.com> | 2014-07-11 19:53:10 +0200 |
commit | 07b9d80604f130c5958e24651e73e889c6e43bb7 (patch) | |
tree | 96b24336593f8220410586133f00886a9976a6ae | |
parent | 55efb2d9f2f3024137cfd28ec0b58c723f044b42 (diff) | |
download | gitlab-ce-07b9d80604f130c5958e24651e73e889c6e43bb7.tar.gz |
Use devise stored_location to redirect after signing for both public and private pages.
-rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/sessions_controller.rb | 14 | ||||
-rw-r--r-- | config/routes.rb | 2 |
3 files changed, 16 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9cc63e5c1b9..d0546a441e1 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -68,7 +68,7 @@ class ApplicationController < ActionController::Base flash[:alert] = "Your account is blocked. Retry when an admin has unblocked it." new_user_session_path else - super + stored_location_for(:redirect) || stored_location_for(resource) || root_path end end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 00000000000..9b7bd94c3a2 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,14 @@ +class SessionsController < Devise::SessionsController + + def new + if request.referer.present? + store_location_for(:redirect, URI(request.referer).path) + end + + super + end + + def create + super + end +end diff --git a/config/routes.rb b/config/routes.rb index 06fb18ac785..f73fd7a87fa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -160,7 +160,7 @@ Gitlab::Application.routes.draw do resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create] - devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords} + devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions } devise_scope :user do get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", as: :omniauth_error |