work on post views
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
class SessionsController < ApplicationController
|
||||
before_filter :member_only, :only => [:destroy]
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
@@ -9,14 +7,14 @@ class SessionsController < ApplicationController
|
||||
if User.authenticate(params[:name], params[:password])
|
||||
@user = User.find_by_name(params[:name])
|
||||
session[:user_id] = @user.id
|
||||
redirect_to(params[:url] || posts_path, :notice => "You have logged in")
|
||||
redirect_to(params[:url] || posts_path, :notice => "You are now logged in.")
|
||||
else
|
||||
render :action => "edit", :flash => "Password was incorrect"
|
||||
redirect_to(new_session_path, :notice => "Password was incorrect.")
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
session[:user_id] = nil
|
||||
redirect_to(posts_path, :notice => "You have logged out")
|
||||
session.delete(:user_id)
|
||||
redirect_to(posts_path, :notice => "You are now logged out.")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user