From 3ba5da30d3eaf6b0f78c38f807ae08a74b3f1517 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Tue, 17 Sep 2019 12:41:03 +0200 Subject: [PATCH] Don't display expiration warning for expiration date in the past If the expiration date of a password is in the past, don't display the expiration warning, as it's not helpful and confuses the user. This can happen after a user whose password was set to be changed on the first login changes it, but probably also in other situations, depending on how many more bugs in Keystone there are around expiring passwords. Change-Id: Ib79f6ef354c456bbdc2d7c1d4371ae15e825b557 --- openstack_auth/views.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openstack_auth/views.py b/openstack_auth/views.py index b41eff0a9a..415e6e792d 100644 --- a/openstack_auth/views.py +++ b/openstack_auth/views.py @@ -10,6 +10,7 @@ # implied. # See the License for the specific language governing permissions and # limitations under the License. +import datetime import logging from django.conf import settings @@ -139,8 +140,9 @@ def login(request): request.session['region_name'] = region_name expiration_time = request.user.time_until_expiration() threshold_days = settings.PASSWORD_EXPIRES_WARNING_THRESHOLD_DAYS - if expiration_time is not None and \ - expiration_time.days <= threshold_days: + if (expiration_time is not None and + expiration_time.days <= threshold_days and + expiration_time > datetime.timedelta(0)): expiration_time = str(expiration_time).rsplit(':', 1)[0] msg = (_('Please consider changing your password, it will expire' ' in %s minutes') %