mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-13 04:06:57 +02:00
feat(auth): email-based login and setup flows
Login page now requires email + password. Setup page adds email and optional display name fields. API endpoints updated to pass email to verifyPassword/setupUser and explicit userId to createSession. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Fred Cabassut
co-authored by
Claude Opus 4.6
parent
59b5e92d91
commit
4dea359362
@@ -8,18 +8,22 @@ export const POST: RequestHandler = async ({ request, cookies }) => {
|
||||
throw error(400, 'Setup already completed');
|
||||
}
|
||||
|
||||
const { password } = await request.json();
|
||||
const { email, displayName, password } = await request.json();
|
||||
|
||||
if (!email) {
|
||||
throw error(400, 'Email is required');
|
||||
}
|
||||
|
||||
if (!password || password.length < 8) {
|
||||
throw error(400, 'Password must be at least 8 characters');
|
||||
}
|
||||
|
||||
const success = await setupUser(password);
|
||||
if (!success) {
|
||||
const user = await setupUser(email, password, displayName);
|
||||
if (!user) {
|
||||
throw error(500, 'Failed to create user');
|
||||
}
|
||||
|
||||
const token = await createSession();
|
||||
const token = await createSession(user.id);
|
||||
cookies.set('session', token, {
|
||||
path: '/',
|
||||
httpOnly: true,
|
||||
|
||||
Reference in New Issue
Block a user