working login, signup, and logout

This commit is contained in:
Ken Johnson
2013-04-25 00:19:00 -04:00
parent 0154fecb0a
commit 47ce08bb20
20 changed files with 74 additions and 17 deletions
+13
View File
@@ -3,9 +3,22 @@ class SessionsController < ApplicationController
skip_before_filter :authenticated, :only => [:new, :create]
def new
redirect_to dashboard_home_path(:dashboard_id => current_user.id) if current_user && current_user.id
end
def create
user = User.authenticate(params[:email], params[:password])
if user
session[:id] = user.id if User.where(:id => user.id).exists?
redirect_to dashboard_home_path(:dashboard_id => user.id)
else
render "new"
end
end
def destroy
reset_session
redirect_to root_path
end
end