From a0249564e2d8e23e6a115c87560f8711ed042a3f Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 8 Oct 2026 15:12:32 -0400 Subject: [PATCH] DRY pass #3: the web asks one question about a password's length (#5373) RegisterView and ResetPasswordView each wrote the min-length check and its message; config.passwordRefusal(password) is that check, the web's side of auth._password_refusal. Co-Authored-By: Claude Opus 5.5 --- frontend/src/stores/config.ts | 9 +++++++++ frontend/src/views/RegisterView.vue | 7 ++----- frontend/src/views/ResetPasswordView.vue | 7 ++----- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/frontend/src/stores/config.ts b/frontend/src/stores/config.ts index 13132d2..0ccaa59 100644 --- a/frontend/src/stores/config.ts +++ b/frontend/src/stores/config.ts @@ -73,6 +73,14 @@ export const useConfigStore = defineStore("config", () => { const minPasswordLength = ref(8); const loaded = ref(false); + // Why the server would refuse this password, said before asking it; null when it + // would take it. The server checks again (auth._password_refusal). + function passwordRefusal(password: string): string | null { + return password.length < minPasswordLength.value + ? `Password must be at least ${minPasswordLength.value} characters.` + : null; + } + async function load(): Promise { if (loaded.value) return; try { @@ -106,6 +114,7 @@ export const useConfigStore = defineStore("config", () => { clients, passwordResetByEmail, minPasswordLength, + passwordRefusal, loaded, load, reload, diff --git a/frontend/src/views/RegisterView.vue b/frontend/src/views/RegisterView.vue index 23be9c2..bc019d7 100644 --- a/frontend/src/views/RegisterView.vue +++ b/frontend/src/views/RegisterView.vue @@ -24,11 +24,8 @@ const error = ref(""); const loading = ref(false); async function submit() { - error.value = ""; - if (password.value.length < config.minPasswordLength) { - error.value = `Password must be at least ${config.minPasswordLength} characters.`; - return; - } + error.value = config.passwordRefusal(password.value) ?? ""; + if (error.value) return; loading.value = true; try { await session.register(email.value, password.value, displayName.value, invite.value || undefined); diff --git a/frontend/src/views/ResetPasswordView.vue b/frontend/src/views/ResetPasswordView.vue index b3d2b89..7714d29 100644 --- a/frontend/src/views/ResetPasswordView.vue +++ b/frontend/src/views/ResetPasswordView.vue @@ -25,11 +25,8 @@ const error = ref(""); const loading = ref(false); async function submit() { - error.value = ""; - if (password.value.length < config.minPasswordLength) { - error.value = `Password must be at least ${config.minPasswordLength} characters.`; - return; - } + error.value = config.passwordRefusal(password.value) ?? ""; + if (error.value) return; if (password.value !== confirm.value) { error.value = "The two passwords don't match."; return;