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 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 15:12:32 -04:00
co-authored by Claude Opus 5.5
parent 8c45725a2a
commit a0249564e2
3 changed files with 13 additions and 10 deletions
+9
View File
@@ -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<void> {
if (loaded.value) return;
try {
@@ -106,6 +114,7 @@ export const useConfigStore = defineStore("config", () => {
clients,
passwordResetByEmail,
minPasswordLength,
passwordRefusal,
loaded,
load,
reload,
+2 -5
View File
@@ -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);
+2 -5
View File
@@ -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;