Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-07-11 14:24:11 +0400
committerMarin Jankovski <marin@gitlab.com>2014-07-11 21:53:10 +0400
commit07b9d80604f130c5958e24651e73e889c6e43bb7 (patch)
tree96b24336593f8220410586133f00886a9976a6ae
parent55efb2d9f2f3024137cfd28ec0b58c723f044b42 (diff)
Use devise stored_location to redirect after signing for both public and private pages.
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/sessions_controller.rb14
-rw-r--r--config/routes.rb2
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