refactor(profile): visual voice picker, playback toggles, danger zone
- Replace voice <select> with a two-column card grid grouped by engine (Kokoro GPU / Pocket TTS CPU / Cloudflare AI); each card has a per-voice sample play/pause button matching AudioPlayer behaviour - Add Announce chapter and Audio mode (Stream/Generate) toggles to a unified Playback row in Preferences; Audio mode toggle disabled for CF AI voices - Remove duplicate PUT /api/settings from the profile page; all writes go directly into audioStore / theme context and the layout's single debounced effect persists them - Add Danger Zone section: collapsible, requires typing username to unlock Delete account button; calls DELETE /api/profile - Add deleteUserAccount() to pocketbase.ts: purges user_settings, user_library, progress, comment_votes, book_ratings, user_subscriptions, notifications, user_sessions then the app_users record - Add DELETE /api/profile server route (auth-guarded)
This commit is contained in:
26
ui/src/routes/api/profile/+server.ts
Normal file
26
ui/src/routes/api/profile/+server.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { deleteUserAccount } from '$lib/server/pocketbase';
|
||||
import { log } from '$lib/server/logger';
|
||||
|
||||
/**
|
||||
* DELETE /api/profile
|
||||
*
|
||||
* Permanently deletes the authenticated user's account and all associated data:
|
||||
* settings, library, progress, votes, ratings, sessions, notifications.
|
||||
*
|
||||
* The app_users record is removed last. The caller should immediately log the
|
||||
* user out (submit the logout form) to clear the session cookie.
|
||||
*/
|
||||
export const DELETE: RequestHandler = async ({ locals }) => {
|
||||
if (!locals.user) error(401, 'Not authenticated');
|
||||
|
||||
try {
|
||||
await deleteUserAccount(locals.user.id, locals.sessionId);
|
||||
} catch (e) {
|
||||
log.error('profile', 'DELETE /api/profile failed', { userId: locals.user.id, err: String(e) });
|
||||
error(500, { message: 'Failed to delete account. Please try again or contact support.' });
|
||||
}
|
||||
|
||||
return json({ ok: true });
|
||||
};
|
||||
Reference in New Issue
Block a user