-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
So, now you can log in to the system and you'll be redirected back to…
… where you were trying to go
- Loading branch information
Showing
7 changed files
with
52 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,3 +1,33 @@ | |||
class ApplicationController < ActionController::Base | class ApplicationController < ActionController::Base | ||
protect_from_forgery | protect_from_forgery | ||
|
|||
# redirect somewhere that will eventually return back to here | |||
def redirect_away(*params) | |||
session[:original_uri] = request.request_uri | |||
redirect_to(*params) | |||
end | |||
|
|||
# returns the person to either the original url from a redirect_away or to a default url | |||
def redirect_back(*params) | |||
uri = session[:original_uri] | |||
session[:original_uri] = nil | |||
if uri | |||
redirect_to uri | |||
else | |||
redirect_to(*params) | |||
end | |||
end | |||
|
|||
protected | |||
|
|||
def confirm_logged_in | |||
unless session[:user_id] | |||
flash[:message] = "Please log in." | |||
redirect_away(:controller => "access", :action => "login") | |||
return false # halts the before_filter | |||
else | |||
return true | |||
end | |||
end | |||
|
|||
end | end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1,3 @@ | |||
%h1 Header | %h1 Header | ||
- unless session[:user_id].nil? | |||
= link_to 'Logout', :controller => "access", :action => "logout" |