forked from mirror/crumbs-original
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
@@ -12,14 +12,14 @@ export const POST: RequestHandler = async ({ request, ...event }) => {
|
||||
requireAdmin(event);
|
||||
const { email, displayName, password, role } = await request.json();
|
||||
|
||||
if (!email || !password) {
|
||||
throw error(400, 'Email and password are required');
|
||||
if (!email) {
|
||||
throw error(400, 'Email is required');
|
||||
}
|
||||
|
||||
if (password.length < 8) {
|
||||
if (password && password.length < 8) {
|
||||
throw error(400, 'Password must be at least 8 characters');
|
||||
}
|
||||
|
||||
const user = await createUser(email, displayName || email.split('@')[0], password, role || 'user');
|
||||
const user = await createUser(email, displayName || email.split('@')[0], password || null, role || 'user');
|
||||
return json(user, { status: 201 });
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user