Created
February 6, 2009 22:35
-
-
Save myobie/59662 to your computer and use it in GitHub Desktop.
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
## Sessions/create | |
class SessionController | |
def create | |
logout_keeping_session! | |
user = User.authenticate(params[:login], params[:password]) | |
if user | |
# Protects against session fixation attacks, causes request forgery | |
# protection if user resubmits an earlier form using back | |
# button. Uncomment if you understand the tradeoffs. | |
# reset_session | |
self.current_user = user | |
new_cookie_flag = (params[:remember_me] == "1") | |
handle_remember_cookie! new_cookie_flag | |
redirect_back_or_default(initial_path_for(current_user)) | |
flash[:notice] = "Logged in successfully" | |
else | |
note_failed_signin | |
@login = params[:login] | |
@remember_me = params[:remember_me] | |
render :action => 'new' | |
end | |
end | |
end | |
class SessionHelper | |
def initial_path_for(user) | |
case user | |
when Student | |
'path' | |
when Councilor | |
'path' | |
when Teacher | |
'path' | |
else | |
'default just in case' | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment