From: Jean-Philippe Lang Date: Sun, 14 Sep 2014 11:38:52 +0000 (+0000) Subject: Code cleanup (#17717). X-Git-Tag: 2.6.0~36 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=5ccbe10d10208ee6ed68b792a782cdd5ebcd64ec;p=redmine.git Code cleanup (#17717). git-svn-id: http://svn.redmine.org/redmine/trunk@13403 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/models/user.rb b/app/models/user.rb index 36594137d..8405fa4b6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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