2
0
Fork 0

feat: add User.prevent_edit flag for account lockdown

specifically this is for sake of the online demo, so a "permanent"
demo user can be established
This commit is contained in:
Lance Edgar 2024-11-24 17:08:55 -06:00
parent 7afb67b4a0
commit 8f182e81dd
2 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,30 @@
"""add user.prevent_edit
Revision ID: 6bf900765500
Revises: ebd75b9feaa7
Create Date: 2024-11-24 16:52:36.773657
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '6bf900765500'
down_revision: Union[str, None] = 'ebd75b9feaa7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# user
op.add_column('user', sa.Column('prevent_edit', sa.Boolean(), nullable=True))
def downgrade() -> None:
# user
op.drop_column('user', 'prevent_edit')

View file

@ -188,6 +188,11 @@ class User(Base):
The default auth logic will prevent login for "inactive" user accounts. The default auth logic will prevent login for "inactive" user accounts.
""") """)
prevent_edit = sa.Column(sa.Boolean(), nullable=True, doc="""
If set, this user account can only be edited by root. User cannot
change their own password.
""")
role_refs = orm.relationship( role_refs = orm.relationship(
'UserRole', 'UserRole',
back_populates='user', back_populates='user',