summaryrefslogtreecommitdiffstats
path: root/app/models/user.rb
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-10 10:26:55 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2015-05-10 10:26:55 +0000
commit51f7060aa8464f51f78403f87b3556a7ffaa1995 (patch)
treecb7a82d8d788a2e71bb57de7e536bd7048e956f8 /app/models/user.rb
parent92833d0b10e7c46477e1485a4bf616649aee544e (diff)
downloadredmine-51f7060aa8464f51f78403f87b3556a7ffaa1995.tar.gz
redmine-51f7060aa8464f51f78403f87b3556a7ffaa1995.zip
Add the ability to expire passwords after a configurable number of days (#19458).
Patch by Holger Just and Go MAEDA. git-svn-id: http://svn.redmine.org/redmine/trunk@14264 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 8811a65fd..5978f06de 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -323,8 +323,19 @@ class User < Principal
return auth_source.allow_password_changes?
end
+ def password_expired?
+ changed_on = self.passwd_changed_on || Time.at(0)
+ period = Setting.password_max_age.to_i
+
+ if period.zero?
+ false
+ else
+ changed_on < period.days.ago
+ end
+ end
+
def must_change_password?
- must_change_passwd? && change_password_allowed?
+ (must_change_passwd? || password_expired?) && change_password_allowed?
end
def generate_password?