mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-10 23:32:27 -05:00
Add email_access_valdiated_at field to user table, populate it
and update it when users have to use their email to interact with Notify service. Initial population: If user has email_auth, set last_validated_at to logged_in_at. If user has sms_auth, set it to created_at. Then: Update email_access_valdiated_at date when: - user with email_auth logs in - new user is created - user resets password when logged out, meaning we send them an email with a link they have to click to reset their password.
This commit is contained in:
43
migrations/versions/0313_email_access_validated_at.py
Normal file
43
migrations/versions/0313_email_access_validated_at.py
Normal file
@@ -0,0 +1,43 @@
|
||||
"""
|
||||
|
||||
Revision ID: 0313_email_access_validated_at
|
||||
Revises: 0312_populate_returned_letters
|
||||
Create Date: 2020-01-28 18:03:22.237386
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '0313_email_access_validated_at'
|
||||
down_revision = '0312_populate_returned_letters'
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('users', sa.Column('email_access_validated_at', sa.DateTime(), nullable=True))
|
||||
# if user has email_auth, set email_access_validated_at on last login, else set it at user created_at date.
|
||||
op.execute("""
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
email_access_validated_at = created_at
|
||||
WHERE
|
||||
auth_type = 'sms_auth'
|
||||
""")
|
||||
op.execute("""
|
||||
UPDATE
|
||||
users
|
||||
SET
|
||||
email_access_validated_at = logged_in_at
|
||||
WHERE
|
||||
auth_type = 'email_auth'
|
||||
""")
|
||||
op.alter_column('users', 'email_access_validated_at', nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('users', 'email_access_validated_at')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user