aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2024-08-27 23:55:09 +0100
committerGravatar Chris Lovering <[email protected]>2024-08-27 23:55:09 +0100
commitace202b82f1b04704314ce0972d4b1d4fe2efc96 (patch)
treec541d16e6a31b8f0d39e30d5427142a250e689ec
parentAdd debug endpoint for creating users (diff)
make pw reset codes unique
-rw-r--r--thallium-backend/migrations/versions/1724787838-e070d9f5f64a_user_auth_columns.py2
-rw-r--r--thallium-backend/src/orm/users.py2
2 files changed, 2 insertions, 2 deletions
diff --git a/thallium-backend/migrations/versions/1724787838-e070d9f5f64a_user_auth_columns.py b/thallium-backend/migrations/versions/1724787838-e070d9f5f64a_user_auth_columns.py
index a70bffa..ff2369a 100644
--- a/thallium-backend/migrations/versions/1724787838-e070d9f5f64a_user_auth_columns.py
+++ b/thallium-backend/migrations/versions/1724787838-e070d9f5f64a_user_auth_columns.py
@@ -22,7 +22,7 @@ def upgrade() -> None:
op.add_column("users", sa.Column("username", sa.String(), nullable=False))
op.add_column("users", sa.Column("password_hash", sa.String(), nullable=False))
op.add_column("users", sa.Column("require_password_change", sa.Boolean(), nullable=False))
- op.add_column("users", sa.Column("password_reset_code", sa.String(), nullable=True))
+ op.add_column("users", sa.Column("password_reset_code", sa.String(), nullable=True, unique=True))
op.add_column("users", sa.Column("active", sa.Boolean(), nullable=False))
op.add_column("users", sa.Column("password_set_at", sa.TIMESTAMP(timezone=True), nullable=False))
op.create_unique_constraint(op.f("users_username_uq"), "users", ["username"])
diff --git a/thallium-backend/src/orm/users.py b/thallium-backend/src/orm/users.py
index 1aa0bfe..d34edbd 100644
--- a/thallium-backend/src/orm/users.py
+++ b/thallium-backend/src/orm/users.py
@@ -16,7 +16,7 @@ class User(UUIDBase, AuditBase, Base):
permissions: Mapped[int]
password_set_at: Mapped[datetime] = mapped_column(TIMESTAMP(timezone=True))
require_password_change: Mapped[bool] = mapped_column(default=True)
- password_reset_code: Mapped[str] = mapped_column(nullable=True)
+ password_reset_code: Mapped[str] = mapped_column(nullable=True, unique=True)
active: Mapped[bool] = mapped_column(default=True)
__table_args__ = (