Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
login fixed
  • Loading branch information
rcb09003 committed Nov 5, 2013
1 parent 3197de5 commit 699a045
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/controllers/users_controller.rb
@@ -1,5 +1,5 @@
class UsersController < ApplicationController
before_action :signed_in_user, only: [:index, :edit, :update, :destroy]
before_action :signed_in_user, only: [:index, :edit, :update, :destroy]
before_action :correct_user, only: [:edit, :update]
before_action :admin_user, only: :destroy

Expand Down Expand Up @@ -48,7 +48,7 @@ before_action :signed_in_user, only: [:index, :edit, :update, :destroy]

# Before filters

def admin_user
def admin_user
redirect_to(root_url) unless current_user.admin?
end

Expand Down
8 changes: 7 additions & 1 deletion app/helpers/sessions_helper.rb
Expand Up @@ -11,17 +11,23 @@ module SessionsHelper
!current_user.nil?
end


def current_user
remember_token = User.encrypt(cookies[:remember_token])
@current_user ||= User.find_by(remember_token: remember_token)
end


def current_user=(user)
@current_user = user
end

def current_user?(user)
user == current_user
end


def sign_out
def sign_out
self.current_user = nil
cookies.delete(:remember_token)
end
Expand Down

0 comments on commit 699a045

Please sign in to comment.