Commit 4fd5d136 authored by Mark Caglienzi's avatar Mark Caglienzi
Browse files

Avoid crash when octofussd returns None for shadowMax. refs #9972

parent 4ef1f7d2
......@@ -81,8 +81,10 @@ class UserListJSON(OctonetMixin, View):
aaData = []
for u in users[start:start+length]:
# refs #9972
shadowLastChange = int(u.get('shadowLastChange', 0))
shadowMax = int(u.get('shadowMax', 0))
# Sometimes this get() will return None (as seen in test instances), so...
shadowMax = int(self.user.get('shadowMax', 0) or 0)
# This get didn't fail in test instances, but just to be on the safe side...
shadowLastChange = int(self.user.get('shadowLastChange', 0) or 0)
last_password_change = epoch + datetime.timedelta(days=shadowLastChange)
next_password_change = last_password_change + datetime.timedelta(days=shadowMax)
expired_password = shadowLastChange == 0 or next_password_change < today
......@@ -132,8 +134,10 @@ class UserMixin(OctonetMixin):
# refs #9972
epoch = datetime.date(1970, 1, 1)
today = datetime.date.today()
shadowLastChange = int(self.user.get('shadowLastChange', 0))
shadowMax = int(self.user.get('shadowMax', 0))
# Sometimes this get() will return None (as seen in test instances), so...
shadowMax = int(self.user.get('shadowMax', 0) or 0)
# This get didn't fail in test instances, but just to be on the safe side...
shadowLastChange = int(self.user.get('shadowLastChange', 0) or 0)
last_password_change = epoch + datetime.timedelta(days=shadowLastChange)
if shadowLastChange:
self.user['last_password_change'] = last_password_change.strftime("%Y-%m-%d")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment