Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

return to return_to after login

  • Loading branch information...
commit 69ba0fd1fa0c65f1a49627ffd38af5d5834bc40c 1 parent a82bac2
@mooktakim authored
View
4 app/controllers/omnisocial/auth_controller.rb
@@ -7,6 +7,8 @@ def new
if current_user?
flash[:notice] = 'You are already signed in. Please sign out if you want to sign in as a different user.'
redirect_to(root_path)
+ else
+ store_location(request.referer)
end
end
@@ -36,7 +38,7 @@ def callback
account.save
end
- redirect_back_or_default(session['return_to'] || root_path)
+ redirect_back_or_default(root_path)
end
def failure
View
13 lib/extensions/action_controller/base.rb
@@ -16,12 +16,19 @@ def require_user
# Utils
- def store_location
- session[:return_to] = request.fullpath
+ def store_location(url)
+ path = URI.parse(url).path.downcase
+ if !request.get? or ['/login', '/logout'].include?(path) or path.match(/^\/auth\//i)
+ session[:return_to] = nil
+ else
+ session[:return_to] = url
+ end
+ rescue
+ session[:return_to] = nil
end
def deny_access
- store_location
+ store_location(request.fullpath)
redirect_to login_path
end
Please sign in to comment.
Something went wrong with that request. Please try again.