summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-23 11:26:04 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-07-23 11:26:04 +0000
commitd74f0bfd5c53962e332c2dd4d30dafaa1105b92b (patch)
treef3eaf66d67c3a87fb34340561bf188d364de623c /app/models/user.rb
parent41bb302594b48152b87c92f196c915f499093bbf (diff)
downloadredmine-d74f0bfd5c53962e332c2dd4d30dafaa1105b92b.tar.gz
redmine-d74f0bfd5c53962e332c2dd4d30dafaa1105b92b.zip
Merged rails-5.1 branch (#23630).
git-svn-id: http://svn.redmine.org/redmine/trunk@16859 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb19
1 files changed, 8 insertions, 11 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 62a0289f0..7cdf78678 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -99,9 +99,6 @@ class User < Principal
attr_accessor :last_before_login_on
attr_accessor :remote_ip
- # Prevents unauthorized assignments
- attr_protected :password, :password_confirmation, :hashed_password
-
LOGIN_LENGTH_LIMIT = 60
MAIL_LENGTH_LIMIT = 60
@@ -771,9 +768,9 @@ class User < Principal
case mail_notification
when 'selected', 'only_my_events'
# user receives notifications for created/assigned issues on unselected projects
- object.author == self || is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.assigned_to_was)
+ object.author == self || is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.previous_assignee)
when 'only_assigned'
- is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.assigned_to_was)
+ is_or_belongs_to?(object.assigned_to) || is_or_belongs_to?(object.previous_assignee)
when 'only_owner'
object.author == self
end
@@ -845,7 +842,7 @@ class User < Principal
# This helps to keep the account secure in case the associated email account
# was compromised.
def destroy_tokens
- if hashed_password_changed? || (status_changed? && !active?)
+ if saved_change_to_hashed_password? || (saved_change_to_status? && !active?)
tokens = ['recovery', 'autologin', 'session']
Token.where(:user_id => id, :action => tokens).delete_all
end
@@ -900,16 +897,16 @@ class User < Principal
}
deliver = false
- if (admin? && id_changed? && active?) || # newly created admin
- (admin? && admin_changed? && active?) || # regular user became admin
- (admin? && status_changed? && active?) # locked admin became active again
+ if (admin? && saved_change_to_id? && active?) || # newly created admin
+ (admin? && saved_change_to_admin? && active?) || # regular user became admin
+ (admin? && saved_change_to_status? && active?) # locked admin became active again
deliver = true
options[:message] = :mail_body_security_notification_add
elsif (admin? && destroyed? && active?) || # active admin user was deleted
- (!admin? && admin_changed? && active?) || # admin is no longer admin
- (admin? && status_changed? && !active?) # admin was locked
+ (!admin? && saved_change_to_admin? && active?) || # admin is no longer admin
+ (admin? && saved_change_to_status? && !active?) # admin was locked
deliver = true
options[:message] = :mail_body_security_notification_remove