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 minPasswordLength = ref(8);
|
||||||
const loaded = ref(false);
|
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> {
|
async function load(): Promise<void> {
|
||||||
if (loaded.value) return;
|
if (loaded.value) return;
|
||||||
try {
|
try {
|
||||||
@@ -106,6 +114,7 @@ export const useConfigStore = defineStore("config", () => {
|
|||||||
clients,
|
clients,
|
||||||
passwordResetByEmail,
|
passwordResetByEmail,
|
||||||
minPasswordLength,
|
minPasswordLength,
|
||||||
|
passwordRefusal,
|
||||||
loaded,
|
loaded,
|
||||||
load,
|
load,
|
||||||
reload,
|
reload,
|
||||||
|
|||||||
@@ -24,11 +24,8 @@ const error = ref("");
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
error.value = "";
|
error.value = config.passwordRefusal(password.value) ?? "";
|
||||||
if (password.value.length < config.minPasswordLength) {
|
if (error.value) return;
|
||||||
error.value = `Password must be at least ${config.minPasswordLength} characters.`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
try {
|
try {
|
||||||
await session.register(email.value, password.value, displayName.value, invite.value || undefined);
|
await session.register(email.value, password.value, displayName.value, invite.value || undefined);
|
||||||
|
|||||||
@@ -25,11 +25,8 @@ const error = ref("");
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
error.value = "";
|
error.value = config.passwordRefusal(password.value) ?? "";
|
||||||
if (password.value.length < config.minPasswordLength) {
|
if (error.value) return;
|
||||||
error.value = `Password must be at least ${config.minPasswordLength} characters.`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (password.value !== confirm.value) {
|
if (password.value !== confirm.value) {
|
||||||
error.value = "The two passwords don't match.";
|
error.value = "The two passwords don't match.";
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user