Created
October 11, 2013 01:05
-
-
Save alexclarkofficial/6928128 to your computer and use it in GitHub Desktop.
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 | |
end | |
def create | |
user = User.find_by(name: params[:session][:name].downcase) | |
if user && user.authenticate(params[:session][:password]) | |
sign_in user | |
redirect_to user | |
else | |
flash[:error] = 'Please enter a valid username or email' # Not quite right! | |
redirect_to root_path | |
end | |
end | |
def destroy | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment