From cdfe84908987d94034ed8bc435084ccdebd8cc30 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 26 Aug 2026 15:38:44 +0000 Subject: feat(admin/users): implement create_verified_user Replaces the dummy stub with a real implementation that: - calls save_user(cursor, email, name, verified=True) to create the user with the verified flag set, bypassing the email verification flow - calls set_user_password to store the hashed credential in user_credentials - returns the newly created User with no roles assigned Co-Authored-By: Claude Sonnet 4.6 Reviewed-By: Frederick M. Muriithi --- gn_auth/auth/authorisation/users/models.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'gn_auth/auth/authorisation/users/models.py') diff --git a/gn_auth/auth/authorisation/users/models.py b/gn_auth/auth/authorisation/users/models.py index ab7a980..21a9627 100644 --- a/gn_auth/auth/authorisation/users/models.py +++ b/gn_auth/auth/authorisation/users/models.py @@ -9,7 +9,7 @@ from ..checks import authorised_p from ..privileges import Privilege from ...db import sqlite3 as db -from ...authentication.users import User +from ...authentication.users import User, save_user, set_user_password def __process_age_clause__(age_desc: str) -> tuple[str, int]: @@ -166,3 +166,22 @@ def delete_users_by_id( cursor.execute( f"DELETE FROM users WHERE user_id IN ({_paramstr})", _ids) return cursor.rowcount + + +def create_credentialed_user( + conn: db.DbConnection, + email: str, + name: str, + password: str, + *, + verified: bool = False +) -> User: + """Create a user with stored password credentials. + + Caller controls the verified flag — pass verified=True to bypass the + normal email-verification flow (e.g. admin provisioning). + """ + with db.cursor(conn) as cursor: + user = save_user(cursor, email, name, verified=verified) + set_user_password(cursor, user, password) + return user -- cgit 1.4.1