mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
misc: migrated to native DAL method
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user