Use devise stored_location to redirect after signing for both public and private pages.

This commit is contained in:
Marin Jankovski 2014-07-11 12:24:11 +02:00
parent 55efb2d9f2
commit 07b9d80604
3 changed files with 16 additions and 2 deletions

View File

@ -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

View 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

View File

@ -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