Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
27 lines (21 sloc) 548 Bytes
class SessionsController < ApplicationController
skip_before_filter :authenticate
def new
end
def create
user = User.authenticate(params[:email], params[:password])
if user
session[:user_id] = user.id
session[:back] ||= user_path(user)
redirect_to session[:back], notice: "Logged in!"
session[:back] = nil
else
flash.now.alert = "Invalid email or password"
render "new"
end
end
def destroy
session[:user_id] = nil
redirect_to root_url, :notice => "Logged out!"
end
end
Something went wrong with that request. Please try again.