mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-13 04:06:57 +02:00
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:
co-authored by
Claude Opus 4.6
parent
7297dc0616
commit
4a280b5932
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user