feat(profile): implement avatar upload functionality and update profile handling

This commit is contained in:
2026-03-29 15:12:34 +02:00
parent 3b57ad4f37
commit a3964eb047
8 changed files with 131 additions and 3 deletions

View File

@@ -12,8 +12,23 @@ export const profileSchema = z.object({
avatarUrl: z
.string()
.trim()
.url("Avatar URL must be a valid URL")
.max(500)
.refine((value) => {
if (!value) {
return true;
}
if (value.startsWith("/uploads/avatars/")) {
return true;
}
try {
const url = new URL(value);
return url.protocol === "http:" || url.protocol === "https:";
} catch {
return false;
}
}, "Avatar must be a valid URL or uploaded file path")
.optional()
.or(z.literal("")),
themeId: z.string().trim().min(1),