mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-17 23:52:24 +00:00
fix(profile): localize the email-conflict message too
The 409 email-conflict branch had a safe, specific message already, but no errorCode - the account-section fallback would have had nothing to translate it through once it stopped echoing json.error verbatim. Give it profile.update.emailInUse so it renders in the active locale like every other profile-save outcome, and propagate errorCode through both route handlers even on the (non-issues) conflict path. Also updates the /api/user/profile route test for the reported scenario directly: a valid timeFormat now lands even when gender in the same PATCH is unsupported, instead of the whole request failing.
This commit is contained in:
1 parent
6f5935aeb4
commit
356888134d
10 files changed
+88
-25
No files matched your search
@@ -20,14 +20,10 @@ export const PUT = apiHandler(async (request: NextRequest) => {
|
||||
|
||||
const result = await applyProfileUpdate(user.id, body, getClientIp(request));
|
||||
if (!result.ok) {
|
||||
const meta = result.errorCode ? { errorCode: result.errorCode } : undefined;
|
||||
return result.issues
|
||||
? apiValidationError(
|
||||
result.message,
|
||||
result.issues,
|
||||
result.status,
|
||||
result.errorCode ? { errorCode: result.errorCode } : undefined,
|
||||
)
|
||||
: apiError(result.message, result.status);
|
||||
? apiValidationError(result.message, result.issues, result.status, meta)
|
||||
: apiError(result.message, result.status, meta);
|
||||
}
|
||||
|
||||
annotate({ action: { name: "auth.profile.update" } });
|
||||
|
||||
Reference in new issue
Block a user