Created
March 26, 2011 11:19
-
-
Save Znow/888212 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
| class SessionsController < ApplicationController | |
| def new | |
| @title = 'Sign In' | |
| end | |
| def create | |
| # Use the authenticate method from the User model along with the parametres of :session to validate the user login | |
| 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 # Signs in the User | |
| redirect_back_or 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