Skip to content

Commit

Permalink
Don't bother eager loading role/privilegs - AR loads then in separate…
Browse files Browse the repository at this point in the history
… queries anyway (not in one).
  • Loading branch information
mvanholstyn committed Aug 9, 2008
1 parent 42ed659 commit 9f7a123
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def set_current_user user

def find_and_set_current_user
if session[:current_user_id]
set_current_user self.class.login_model.find(session[:current_user_id], :include => {:role => :privileges })
set_current_user self.class.login_model.find(session[:current_user_id])
elsif cookies[:remember_me_token]
model = self.class.login_model.find(:first, :conditions => ["remember_me_token = ? AND remember_me_token_expires_at >= ?", cookies[:remember_me_token], Time.now], :include => {:role => :privileges })
if model
Expand Down
2 changes: 1 addition & 1 deletion lib/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module SingletonMethods
# Attempts to find a user by the passed in attributes. The param :password will
# be removed and will be checked against the password of the user found (if any).
def login(params)
if not params.blank? and user = self.find_by_email_address(params[:email_address], :include => {:role => :privileges})
if not params.blank? and user = self.find_by_email_address(params[:email_address])
self.hash_password(params[:password], user.salt) == user.password_hash ? user : nil
end
end
Expand Down

0 comments on commit 9f7a123

Please sign in to comment.