##// END OF EJS Templates
Do not autologin if more that one token is found (#3351)....
Jean-Philippe Lang -
r2643:b87753c90d2b
parent child
Show More
@@ -128,12 +128,16 class User < ActiveRecord::Base
128 128
129 129 # Returns the user who matches the given autologin +key+ or nil
130 130 def self.try_to_autologin(key)
131 token = Token.find_by_action_and_value('autologin', key)
132 if token && (token.created_on > Setting.autologin.to_i.day.ago) && token.user && token.user.active?
131 tokens = Token.find_all_by_action_and_value('autologin', key)
132 # Make sure there's only 1 token that matches the key
133 if tokens.size == 1
134 token = tokens.first
135 if (token.created_on > Setting.autologin.to_i.day.ago) && token.user && token.user.active?
133 136 token.user.update_attribute(:last_login_on, Time.now)
134 137 token.user
135 138 end
136 139 end
140 end
137 141
138 142 # Return user's full name for display
139 143 def name(formatter = nil)
General Comments 0
You need to be logged in to leave comments. Login now