Use devise stored_location to redirect after signing for both public and private pages.
This commit is contained in:
parent
55efb2d9f2
commit
07b9d80604
3 changed files with 16 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
14
app/controllers/sessions_controller.rb
Normal file
14
app/controllers/sessions_controller.rb
Normal file
|
@ -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
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue