mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
- Settings page: edit display name/email, change password - Admin user management page: create/delete users, toggle roles - Profile update API endpoint (PUT /api/auth/profile) - Settings link added to sidebar navigation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
17 lines
542 B
TypeScript
17 lines
542 B
TypeScript
import { json, error } from '@sveltejs/kit';
|
|
import type { RequestHandler } from './$types.js';
|
|
import { getUserId } from '$lib/server/api-utils.js';
|
|
import { updateUserProfile } from '$lib/server/auth.js';
|
|
|
|
export const PUT: RequestHandler = async ({ request, ...event }) => {
|
|
const userId = getUserId(event);
|
|
const { displayName, email } = await request.json();
|
|
|
|
if (email !== undefined && !email) {
|
|
throw error(400, 'Email cannot be empty');
|
|
}
|
|
|
|
updateUserProfile(userId, { displayName, email });
|
|
return json({ success: true });
|
|
};
|