fix: include is_admin and household_name in get_user_by_callback_token query
CI / test-and-package (push) Successful in 33s
CI / test-and-package (push) Successful in 33s
The auto-login route needs these fields to populate the session, but the query only selected id, username, household_id. Added JOIN with households table and selected is_admin + household_name.
This commit is contained in:
@@ -233,7 +233,9 @@ def get_user_by_callback_token(token: str) -> dict | None:
|
|||||||
"""Look up a user by their ntfy callback token."""
|
"""Look up a user by their ntfy callback token."""
|
||||||
with get_db() as db:
|
with get_db() as db:
|
||||||
row = db.execute(
|
row = db.execute(
|
||||||
"SELECT id, username, household_id FROM users WHERE callback_token = ?",
|
"SELECT u.id, u.username, u.is_admin, u.household_id, h.name AS household_name "
|
||||||
|
"FROM users u JOIN households h ON u.household_id = h.id "
|
||||||
|
"WHERE u.callback_token = ?",
|
||||||
(token,),
|
(token,),
|
||||||
).fetchone()
|
).fetchone()
|
||||||
return dict(row) if row else None
|
return dict(row) if row else None
|
||||||
|
|||||||
Reference in New Issue
Block a user