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:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user