feat: allow creating OAuth-only users without a password

Admin can now toggle "OAuth-only (no password)" when creating a user.
These users have no password hash and authProvider set to 'none', so
they can only log in via an OAuth/SSO provider.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Frederic Cabassut
2026-03-09 11:35:12 +01:00
co-authored by Claude Opus 4.6
parent 7297dc0616
commit 4a280b5932
3 changed files with 31 additions and 18 deletions
+3 -3
View File
@@ -194,10 +194,10 @@ export function revokeAllSessions(userId: number, exceptToken?: string): void {
export async function createUser(
email: string,
displayName: string,
password: string,
password: string | null,
role: 'admin' | 'user' = 'user'
): Promise<User> {
const hash = await argon2.hash(password);
const hash = password ? await argon2.hash(password) : null;
const result = db
.insert(users)
.values({
@@ -205,7 +205,7 @@ export async function createUser(
displayName,
role,
passwordHash: hash,
authProvider: 'password',
authProvider: password ? 'password' : 'none',
createdAt: new Date()
})
.returning()