diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-10 10:26:55 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2015-05-10 10:26:55 +0000 |
commit | 51f7060aa8464f51f78403f87b3556a7ffaa1995 (patch) | |
tree | cb7a82d8d788a2e71bb57de7e536bd7048e956f8 /app/models/user.rb | |
parent | 92833d0b10e7c46477e1485a4bf616649aee544e (diff) | |
download | redmine-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.rb | 13 |
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? |