]> source.dussan.org Git - redmine.git/commitdiff
Code cleanup (#17717).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Sep 2014 11:38:52 +0000 (11:38 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sun, 14 Sep 2014 11:38:52 +0000 (11:38 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@13403 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/user.rb

index 36594137d9302d12ee69b1eaaa3446b311ebcc97..8405fa4b6d579667e86eefae837043228ee6b7df 100644 (file)
@@ -687,10 +687,12 @@ class User < Principal
   # was compromised.
   def destroy_tokens
     tokens  = []
-    tokens |= ['recovery', 'autologin'] if changes.has_key?('hashed_password')
-    tokens |= ['recovery'] if changes.has_key?('mail')
+    tokens |= ['recovery', 'autologin'] if hashed_password_changed?
+    tokens |= ['recovery'] if mail_changed?
 
-    Token.delete_all(['user_id = ? AND action IN (?)', self.id, tokens]) if tokens.any?
+    if tokens.any?
+      Token.where(:user_id => id, :action => tokens).delete_all
+    end
   end
 
   # Removes references that are not handled by associations