diff options
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 96923900e..f48317610 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -175,8 +175,14 @@ class User < ActiveRecord::Base 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 + tokens = Token.find_all_by_action_and_value('autologin', key) + # Make sure there's only 1 token that matches the key + if tokens.size == 1 + token = tokens.first + if (token.created_on > Setting.autologin.to_i.day.ago) && token.user && token.user.active? + token.user + end + end end # Makes find_by_mail case-insensitive |