Fixed: When logging in via an autologin cookie the user's last_login_on should be updated (#2820).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2524 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
+9
-5
@@ -126,6 +126,15 @@ class User < ActiveRecord::Base
|
||||
rescue => text
|
||||
raise text
|
||||
end
|
||||
|
||||
# Returns the user who matches the given autologin +key+ or nil
|
||||
def self.try_to_autologin(key)
|
||||
token = Token.find_by_action_and_value('autologin', key)
|
||||
if token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user && token.user.active?
|
||||
token.user.update_attribute(:last_login_on, Time.now)
|
||||
token.user
|
||||
end
|
||||
end
|
||||
|
||||
# Return user's full name for display
|
||||
def name(formatter = nil)
|
||||
@@ -199,11 +208,6 @@ class User < ActiveRecord::Base
|
||||
token && token.user.active? ? token.user : nil
|
||||
end
|
||||
|
||||
def self.find_by_autologin_key(key)
|
||||
token = Token.find_by_action_and_value('autologin', key)
|
||||
token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user.active? ? token.user : nil
|
||||
end
|
||||
|
||||
# Makes find_by_mail case-insensitive
|
||||
def self.find_by_mail(mail)
|
||||
find(:first, :conditions => ["LOWER(mail) = ?", mail.to_s.downcase])
|
||||
|
||||
Reference in New Issue
Block a user