Created
December 20, 2010 00:53
-
-
Save mthomas/747890 to your computer and use it in GitHub Desktop.
SessionsController
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
class SessionsController < ApplicationController | |
before_filter :require_no_user, :only => [:new, :create] | |
before_filter :require_user, :only => :destroy | |
def new | |
end | |
def create | |
authenticate! | |
if logged_in? | |
flash[:notice] = "Login successful!" | |
redirect_to current_user | |
end | |
end | |
def destroy | |
logout | |
flash[:notice] = "Logout successful!" | |
redirect_to root_url | |
end | |
def unauthenticated | |
flash[:error] = "Incorrect email/password combination" | |
redirect_to new_session_url | |
return false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment