Skip to content

Commit 6d5aa35

Browse files
brianfrommclaude
andauthored
fix: display friendly error message for password validation on signup (#5563)
Co-authored-by: Claude <noreply@anthropic.com>
1 parent a3b5584 commit 6d5aa35

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

frontend/src/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@
102102
"username": "Username",
103103
"usernameTaken": "Username already taken",
104104
"wrongCredentials": "Wrong credentials",
105+
"passwordTooShort": "Password must be at least {min} characters",
105106
"logout_reasons": {
106107
"inactivity": "You have been logged out due to inactivity."
107108
}

frontend/src/utils/auth.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ export async function signup(username: string, password: string) {
101101
});
102102

103103
if (res.status !== 200) {
104-
throw new StatusError(`${res.status} ${res.statusText}`, res.status);
104+
const body = await res.text();
105+
throw new StatusError(
106+
body || `${res.status} ${res.statusText}`,
107+
res.status
108+
);
105109
}
106110
}
107111

frontend/src/views/Login.vue

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ const submit = async (event: Event) => {
112112
error.value = t("login.usernameTaken");
113113
} else if (e.status === 403) {
114114
error.value = t("login.wrongCredentials");
115+
} else if (e.status === 400) {
116+
const match = e.message.match(/minimum length is (\d+)/);
117+
if (match) {
118+
error.value = t("login.passwordTooShort", { min: match[1] });
119+
} else {
120+
error.value = e.message;
121+
}
115122
} else {
116123
$showError(e);
117124
}

0 commit comments

Comments
 (0)