mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 01:38:24 -04:00
Use utils function to parse datetime strings
Rather than hard-coding a format string in a bunch of different places we can use the function we already have in utils. This commit also refactors some logic around password resets to put the date-parsing changes in the most sensible bit of the codebase, so it’s clearer what the intention of the view-layer code is.
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import json
|
||||
from datetime import datetime
|
||||
|
||||
from flask import (
|
||||
current_app,
|
||||
@@ -29,8 +28,7 @@ def new_password(token):
|
||||
|
||||
email_address = json.loads(token_data)['email']
|
||||
user = User.from_email_address(email_address)
|
||||
if user.password_changed_at and datetime.strptime(user.password_changed_at, '%Y-%m-%d %H:%M:%S.%f') > \
|
||||
datetime.strptime(json.loads(token_data)['created_at'], '%Y-%m-%d %H:%M:%S.%f'):
|
||||
if user.password_changed_more_recently_than(json.loads(token_data)['created_at']):
|
||||
flash('The link in the email has already been used')
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user