feat(28-01): add account management routes for password, email, and deletion

Creates /api/account routes with password change (verifies current first),
email update, has-password check, and account deletion with public setup
anonymization. Adds Zod validation schemas and registers routes in index.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-12 17:47:17 +02:00
parent fcd8279d79
commit e8207a33f9
5 changed files with 220 additions and 17 deletions

View File

@@ -127,3 +127,17 @@ export const updateProfileSchema = z.object({
avatarUrl: z.string().optional(),
bio: z.string().max(500).optional(),
});
// Account management schemas (per D-05)
export const changePasswordSchema = z.object({
currentPassword: z.string().min(1),
newPassword: z.string().min(8),
});
export const changeEmailSchema = z.object({
newEmail: z.string().email(),
});
export const deleteAccountSchema = z.object({
confirmation: z.literal("DELETE"),
});

View File

@@ -12,11 +12,14 @@ import type {
} from "../db/schema.ts";
import type {
bulkUpsertGlobalItemsSchema,
changeEmailSchema,
changePasswordSchema,
createCandidateSchema,
createCategorySchema,
createItemSchema,
createSetupSchema,
createThreadSchema,
deleteAccountSchema,
reorderCandidatesSchema,
resolveThreadSchema,
searchGlobalItemsSchema,
@@ -67,3 +70,8 @@ export type SetupItem = typeof setupItems.$inferSelect;
export type GlobalItem = typeof globalItems.$inferSelect;
export type Tag = typeof tags.$inferSelect;
export type GlobalItemTag = typeof globalItemTags.$inferSelect;
// Account management types
export type ChangePassword = z.infer<typeof changePasswordSchema>;
export type ChangeEmail = z.infer<typeof changeEmailSchema>;
export type DeleteAccount = z.infer<typeof deleteAccountSchema>;