From 4bd3e917c208e3943ed7504b0e76c3a6c20ea891 Mon Sep 17 00:00:00 2001 From: Akhil Meka Date: Wed, 3 Sep 2025 10:50:12 +0530 Subject: [PATCH] fix: updated faliedLoginCount to failedLoginCount --- src/auth/auth.route.ts | 20 +++++++++----------- src/user/user.schema.ts | 2 +- src/user/user.service.ts | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/auth/auth.route.ts b/src/auth/auth.route.ts index c8639c1..f7ec9b6 100644 --- a/src/auth/auth.route.ts +++ b/src/auth/auth.route.ts @@ -45,7 +45,7 @@ export async function authRoutes(fastify: FastifyInstance) { userInDB.passwordHash = hashedPassword; userInDB.blocked = false; - userInDB.faliedLoginCount = 0; + userInDB.failedLoginCount = 0; await userInDB.save(); } catch (err) { return err; @@ -88,17 +88,15 @@ export async function authRoutes(fastify: FastifyInstance) { const match = await verify(userInDB.passwordHash, password); if (!match) { - if (!userInDB.faliedLoginCount) userInDB.faliedLoginCount = 0; - if (userInDB.faliedLoginCount >= 4) userInDB.blocked = true; - userInDB.faliedLoginCount++; + if (!userInDB.failedLoginCount) userInDB.failedLoginCount = 0; + if (userInDB.failedLoginCount >= 4) userInDB.blocked = true; + userInDB.failedLoginCount++; await userInDB.save(); - return res - .code(401) - .send({ - error: "invalid email or password", - failedLoginCount: userInDB.faliedLoginCount, - }); + return res.code(401).send({ + error: "invalid email or password", + failedLoginCount: userInDB.failedLoginCount, + }); } const newSession = await createSession( @@ -108,7 +106,7 @@ export async function authRoutes(fastify: FastifyInstance) { ); userInDB.lastLogin = new Date(); - userInDB.faliedLoginCount = 0; + userInDB.failedLoginCount = 0; await userInDB.save(); res.send({ session_token: newSession.sid }); diff --git a/src/user/user.schema.ts b/src/user/user.schema.ts index 6874008..0fd0f50 100644 --- a/src/user/user.schema.ts +++ b/src/user/user.schema.ts @@ -52,7 +52,7 @@ const userSchema = new mongoose.Schema({ lastLogin: Date, dev: Boolean, blocked: Boolean, - faliedLoginCount: { + failedLoginCount: { type: Number, default: 0, }, diff --git a/src/user/user.service.ts b/src/user/user.service.ts index 00f557c..9b61b05 100644 --- a/src/user/user.service.ts +++ b/src/user/user.service.ts @@ -39,7 +39,7 @@ export async function createUser( status: input.password ? "active" : "invited", passwordHash: hashedPassword, blocked: false, - faliedLoginCount: 0, + failedLoginCount: 0, ...input, });