mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Format email_access_validated_at when serializing
This is to bring it in line with other serialized dates in User model, like logged_in_at and password_changed_at. Also get rid of check if password_changed_at has value, as it is a non-nullable column, so it needs to always have value. Also set a default value for email_access_validated_at, to bring it in line with other non-nullable columns.
This commit is contained in:
@@ -114,7 +114,9 @@ class User(db.Model):
|
||||
platform_admin = db.Column(db.Boolean, nullable=False, default=False)
|
||||
current_session_id = db.Column(UUID(as_uuid=True), nullable=True)
|
||||
auth_type = db.Column(db.String, db.ForeignKey('auth_type.name'), index=True, nullable=False, default=SMS_AUTH_TYPE)
|
||||
email_access_validated_at = db.Column(db.DateTime, index=False, unique=False, nullable=False)
|
||||
email_access_validated_at = db.Column(
|
||||
db.DateTime, index=False, unique=False, nullable=False, default=datetime.datetime.utcnow
|
||||
)
|
||||
|
||||
# either email auth or a mobile number must be provided
|
||||
CheckConstraint("auth_type = 'email_auth' or mobile_number is not null")
|
||||
@@ -163,15 +165,11 @@ class User(db.Model):
|
||||
'auth_type': self.auth_type,
|
||||
'current_session_id': self.current_session_id,
|
||||
'failed_login_count': self.failed_login_count,
|
||||
'email_access_validated_at': self.email_access_validated_at,
|
||||
'email_access_validated_at': self.email_access_validated_at.strftime(DATETIME_FORMAT),
|
||||
'logged_in_at': self.logged_in_at.strftime(DATETIME_FORMAT) if self.logged_in_at else None,
|
||||
'mobile_number': self.mobile_number,
|
||||
'organisations': [x.id for x in self.organisations if x.active],
|
||||
'password_changed_at': (
|
||||
self.password_changed_at.strftime(DATETIME_FORMAT_NO_TIMEZONE)
|
||||
if self.password_changed_at
|
||||
else None
|
||||
),
|
||||
'password_changed_at': self.password_changed_at.strftime(DATETIME_FORMAT_NO_TIMEZONE),
|
||||
'permissions': self.get_permissions(),
|
||||
'platform_admin': self.platform_admin,
|
||||
'services': [x.id for x in self.services if x.active],
|
||||
|
||||
Reference in New Issue
Block a user