Fixes login email test

This commit is contained in:
pikiou 2021-11-26 05:14:08 +01:00
parent f952e24884
commit acdae94b31
2 changed files with 6 additions and 3 deletions

View File

@ -27,11 +27,11 @@ describe("signIn with", () => {
})
it("invalid password length", async () => {
await expect(signIn("my.email@gmail.com", "11011")).rejects.toThrow("Mot de passe invalid")
await expect(signIn("my.email@gmail.com", "123")).rejects.toThrow("Mot de passe trop court")
})
it("empty password", async () => {
await expect(signIn("my.email@gmail.com", " ")).rejects.toThrow("Mot de passe invalid")
await expect(signIn("my.email@gmail.com", " ")).rejects.toThrow("Mot de passe nécessaire")
})
it("wrong password", async () => {

View File

@ -32,8 +32,11 @@ export async function signIn(rawEmail: string, rawPassword: string): Promise<Mem
}
const password = rawPassword.replace(/^\s*/, "").replace(/\s*$/, "")
if (password.length === 0) {
throw Error("Mot de passe nécessaire")
}
if (password.length < passwordMinLength) {
throw Error("Mot de passe invalid")
throw Error("Mot de passe trop court")
}
const membres: Membre[] = await listGet()