Created
March 2, 2011 17:25
-
-
Save buethling/851321 to your computer and use it in GitHub Desktop.
rails session controller
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
class SessionsController < ApplicationController | |
def new | |
@title = "Sign in" | |
end | |
def create | |
user = User.authenticate(params[:session][:email], | |
params[:session][:password]) | |
if user.nil? | |
flash.now[:error] = "Invalid email/password combination." | |
@title = "Sign in" | |
render 'new' | |
else | |
sign_in user | |
redirect_to user | |
end | |
end | |
def destroy | |
sign_out | |
redirect_to root_path | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment