Permalink
Browse files

Rememer original user location during login

  • Loading branch information...
1 parent 3ed1db3 commit 89b89200d3b3b3152e8d7b18fbcaef2cb8e4c736 @rwdaigle committed Oct 12, 2012
Showing with 3 additions and 7 deletions.
  1. +1 −1 app/controllers/application_controller.rb
  2. +1 −5 app/controllers/sessions_controller.rb
  3. +1 −1 config/routes.rb
@@ -20,7 +20,7 @@ def user_logged_in?
end
def force_user_login
- redirect_to login_path unless user_logged_in?
+ redirect_to("/auth/github?origin=#{request.fullpath}") unless user_logged_in?
end
def current_user
@@ -1,9 +1,5 @@
class SessionsController < ApplicationController
- def login
- redirect_to "/auth/github"
- end
-
def logout
log_out_user
redirect_to root_path
@@ -15,7 +11,7 @@ def create
log({ns: self.class, fn: __method__, measure: true, at: 'login'}, user)
if(user.fetched?)
log({ns: self.class, fn: __method__, measure: true, at: 'repeat-login'}, user)
- redirect_to search_gists_path
+ redirect_to(request.env['omniauth.origin'] || search_gists_path)
else
log({ns: self.class, fn: __method__, measure: true, at: 'first-login'}, user)
QC.enqueue("GistFetcher.fetch_user", user.id)
View
@@ -3,7 +3,7 @@
root :to => 'homes#index'
# OAuth/session management
- match '/login', to: 'sessions#login', :as => :login
+ # match '/login', to: 'sessions#login', :as => :login
match '/logout', to: 'sessions#logout', :as => :logout
match '/auth/github/callback', to: 'sessions#create', :via => [:post, :get], :as => :github_auth_callback
match '/auth/failure', to: 'sessions#failure'

0 comments on commit 89b8920

Please sign in to comment.