fix : 12 to 6 for password
This commit is contained in:
@@ -16,7 +16,7 @@ async function mutate(request: Request) {
|
|||||||
const password = input && typeof input === "object" && "password" in input ? input.password : undefined;
|
const password = input && typeof input === "object" && "password" in input ? input.password : undefined;
|
||||||
const newPassword = input && typeof input === "object" && "newPassword" in input ? input.newPassword : undefined;
|
const newPassword = input && typeof input === "object" && "newPassword" in input ? input.newPassword : undefined;
|
||||||
const value = password ?? newPassword;
|
const value = password ?? newPassword;
|
||||||
if (typeof value !== "string" || value.length < 12 || value.length > 128) {
|
if (typeof value !== "string" || value.length < 6 || value.length > 128) {
|
||||||
throw new HttpError(400, "invalid-password-length");
|
throw new HttpError(400, "invalid-password-length");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ export function AccountForm({ mode, siteKey, nextPath }: {
|
|||||||
<CardContent className="flex flex-col gap-4"><form onSubmit={submit}><FieldGroup>
|
<CardContent className="flex flex-col gap-4"><form onSubmit={submit}><FieldGroup>
|
||||||
{register && <Field><FieldLabel htmlFor="name">ชื่อ</FieldLabel><Input id="name" name="name" required maxLength={100} /></Field>}
|
{register && <Field><FieldLabel htmlFor="name">ชื่อ</FieldLabel><Input id="name" name="name" required maxLength={100} /></Field>}
|
||||||
<Field><FieldLabel htmlFor="email">อีเมล</FieldLabel><Input id="email" name="email" type="email" required autoComplete="email" /></Field>
|
<Field><FieldLabel htmlFor="email">อีเมล</FieldLabel><Input id="email" name="email" type="email" required autoComplete="email" /></Field>
|
||||||
<Field><FieldLabel htmlFor="password">รหัสผ่าน</FieldLabel><Input id="password" name="password" type="password" required minLength={12} autoComplete={register ? "new-password" : "current-password"} /></Field>
|
<Field><FieldLabel htmlFor="password">รหัสผ่าน</FieldLabel><Input id="password" name="password" type="password" required minLength={6} autoComplete={register ? "new-password" : "current-password"} /></Field>
|
||||||
{captcha && <div ref={container} />}
|
{captcha && <div ref={container} />}
|
||||||
<Button type="submit" disabled={busy || (captcha && !token)}>{busy ? "กำลังดำเนินการ..." : register ? "สมัครสมาชิก" : "เข้าสู่ระบบ"}</Button>
|
<Button type="submit" disabled={busy || (captcha && !token)}>{busy ? "กำลังดำเนินการ..." : register ? "สมัครสมาชิก" : "เข้าสู่ระบบ"}</Button>
|
||||||
</FieldGroup></form>
|
</FieldGroup></form>
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ describe("actual administrator session boundary", () => {
|
|||||||
mocks.session.mockResolvedValue(null);
|
mocks.session.mockResolvedValue(null);
|
||||||
await expect(requireAdmin()).rejects.toMatchObject({ status: 401 });
|
await expect(requireAdmin()).rejects.toMatchObject({ status: 401 });
|
||||||
});
|
});
|
||||||
it("defaults accounts to user and requires strong new passwords", async () => {
|
it("defaults accounts to user and requires six-character new passwords", async () => {
|
||||||
(await import("./server")).getAuth();
|
(await import("./server")).getAuth();
|
||||||
const options = mocks.auth.mock.calls.at(-1)![0];
|
const options = mocks.auth.mock.calls.at(-1)![0];
|
||||||
expect(options.emailAndPassword).toMatchObject({ disableSignUp: false, minPasswordLength: 12 });
|
expect(options.emailAndPassword).toMatchObject({ disableSignUp: false, minPasswordLength: 6 });
|
||||||
expect(options.plugins).toContainEqual({ defaultRole: "user" });
|
expect(options.plugins).toContainEqual({ defaultRole: "user" });
|
||||||
expect(options.rateLimit.customStorage.consume).toBeTypeOf("function");
|
expect(options.rateLimit.customStorage.consume).toBeTypeOf("function");
|
||||||
expect(options.databaseHooks).toBeUndefined();
|
expect(options.databaseHooks).toBeUndefined();
|
||||||
|
|||||||
+1
-1
@@ -53,7 +53,7 @@ function createAuth() {
|
|||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
disableSignUp: false,
|
disableSignUp: false,
|
||||||
minPasswordLength: 12,
|
minPasswordLength: 6,
|
||||||
maxPasswordLength: 128,
|
maxPasswordLength: 128,
|
||||||
},
|
},
|
||||||
advanced: {
|
advanced: {
|
||||||
|
|||||||
Reference in New Issue
Block a user