Skip to content

Instantly share code, notes, and snippets.

@mthomas
Created December 20, 2010 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mthomas/747890 to your computer and use it in GitHub Desktop.
Save mthomas/747890 to your computer and use it in GitHub Desktop.
SessionsController
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