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