misc: migrated to native DAL method

This commit is contained in:
Sheen Capadngan
2024-05-27 11:01:22 +08:00
parent 59c8dc3cda
commit 3639a7fc18
2 changed files with 2 additions and 16 deletions

View File

@@ -314,7 +314,7 @@ export const authLoginServiceFactory = ({
try {
const updatedUser = await userDAL.transaction(async (tx) => {
const PROGRESSIVE_DELAY_INTERVAL = 3;
const user = await userDAL.incrementFailedMfaAttempt(userId, tx);
const user = await userDAL.updateById(userId, { $incr: { consecutiveFailedMfaAttempts: 1 } }, tx);
if (!user) {
throw new Error("User not found");

View File

@@ -143,19 +143,6 @@ export const userDALFactory = (db: TDbClient) => {
}
};
const incrementFailedMfaAttempt = async (userId: string, tx?: Knex) => {
try {
const [user] = await (tx || db)(TableName.Users)
.where("id", userId)
.increment("consecutiveFailedMfaAttempts", 1)
.returning("*");
return user;
} catch (error) {
throw new DatabaseError({ error, name: "Increment Failed MFA Attempt" });
}
};
return {
...userOrm,
findUserByUsername,
@@ -168,7 +155,6 @@ export const userDALFactory = (db: TDbClient) => {
upsertUserEncryptionKey,
createUserEncryption,
findOneUserAction,
createUserAction,
incrementFailedMfaAttempt
createUserAction
};
};