Migration: properly handle field-specific errors.

master
Tom Hacohen 4 years ago
parent 094983ad47
commit 0e4e5b46ad

@ -188,7 +188,24 @@ export function WizardAccountPage(props: OurPagePropsType & { setEtebase: (eteba
props.next?.(); props.next?.();
setProgress("Done"); setProgress("Done");
} catch (e) { } catch (e) {
if (e instanceof Etebase.UnauthorizedError) { if ((e instanceof Etebase.HttpError) && (e.content)) {
let found = false;
if (e.content.errors) {
for (const field of e.content.errors) {
if (field.field === "user.username") {
errors.errorEmail = field.detail;
found = true;
} else if (!field.field) {
errors.errorGeneral = field.detail;
found = true;
}
}
}
if (!found) {
errors.errorGeneral = e.content.detail ?? e.toString();
}
} else if (e instanceof Etebase.UnauthorizedError) {
errors.errorGeneral = "Wrong username or password"; errors.errorGeneral = "Wrong username or password";
} else { } else {
errors.errorGeneral = e.toString(); errors.errorGeneral = e.toString();

Loading…
Cancel
Save