mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-27 17:38:17 -04:00
Merge pull request #478 from alphagov/make-password_changed_at-not-null
Users.password_changed_at not nullable
This commit is contained in:
@@ -47,7 +47,8 @@ class User(db.Model):
|
||||
onupdate=datetime.datetime.utcnow)
|
||||
_password = db.Column(db.String, index=False, unique=False, nullable=False)
|
||||
mobile_number = db.Column(db.String, index=False, unique=False, nullable=False)
|
||||
password_changed_at = db.Column(db.DateTime, index=False, unique=False, nullable=True)
|
||||
password_changed_at = db.Column(db.DateTime, index=False, unique=False, nullable=False,
|
||||
default=datetime.datetime.utcnow)
|
||||
logged_in_at = db.Column(db.DateTime, nullable=True)
|
||||
failed_login_count = db.Column(db.Integer, nullable=False, default=0)
|
||||
state = db.Column(db.String, nullable=False, default='pending')
|
||||
|
||||
28
migrations/versions/0034_pwd_changed_at_not_null.py
Normal file
28
migrations/versions/0034_pwd_changed_at_not_null.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""empty message
|
||||
|
||||
Revision ID: 0034_pwd_changed_at_not_null
|
||||
Revises: 0033_api_key_type
|
||||
Create Date: 2016-06-28 10:37:25.389020
|
||||
|
||||
"""
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0034_pwd_changed_at_not_null'
|
||||
down_revision = '0033_api_key_type'
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
def upgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.get_bind()
|
||||
op.execute('update users set password_changed_at = created_at where password_changed_at is null')
|
||||
op.alter_column('users', 'password_changed_at', nullable=False)
|
||||
### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('users', 'password_changed_at', nullable=True)
|
||||
### end Alembic commands ###
|
||||
@@ -70,7 +70,6 @@ def test_post_user(notify_api, notify_db, notify_db_session):
|
||||
"email_address": "user@digital.cabinet-office.gov.uk",
|
||||
"password": "password",
|
||||
"mobile_number": "+447700900986",
|
||||
"password_changed_at": None,
|
||||
"logged_in_at": None,
|
||||
"state": "active",
|
||||
"failed_login_count": 0,
|
||||
@@ -100,7 +99,6 @@ def test_post_user_missing_attribute_email(notify_api, notify_db, notify_db_sess
|
||||
"name": "Test User",
|
||||
"password": "password",
|
||||
"mobile_number": "+447700900986",
|
||||
"password_changed_at": None,
|
||||
"logged_in_at": None,
|
||||
"state": "active",
|
||||
"failed_login_count": 0,
|
||||
@@ -129,7 +127,6 @@ def test_post_user_missing_attribute_password(notify_api, notify_db, notify_db_s
|
||||
"name": "Test User",
|
||||
"email_address": "user@digital.cabinet-office.gov.uk",
|
||||
"mobile_number": "+447700900986",
|
||||
"password_changed_at": None,
|
||||
"logged_in_at": None,
|
||||
"state": "active",
|
||||
"failed_login_count": 0,
|
||||
|
||||
Reference in New Issue
Block a user