Created
September 29, 2011 23:57
-
-
Save jonpaul/1252282 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def new | |
end | |
def create | |
user = User.authenticate(params[:login], params[:password]) | |
if user | |
session[:user_id] = user.id | |
redirect_to_target_or_default root_url, :notice => "Logged in successfully." | |
else | |
flash.now[:alert] = "Invalid login or password." | |
render :action => 'new' | |
end | |
end | |
def destroy | |
session[:user_id] = nil | |
redirect_to root_url, :notice => "You have been logged out." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment