fix(models): update user and token operations to use centralized functions

This commit is contained in:
Danny Avila 2025-05-30 13:59:30 -04:00
parent 6e278f6932
commit 3831ad8202
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
10 changed files with 48 additions and 58 deletions

View file

@ -1,8 +1,6 @@
const mongoose = require('mongoose');
const { webcrypto } = require('node:crypto');
const { hashBackupCode, decryptV3, decryptV2 } = require('~/server/utils/crypto');
const User = require('~/db/models').User;
const { updateUser } = require('~/models');
// Base32 alphabet for TOTP secret encoding.
const BASE32_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
@ -174,7 +172,7 @@ const verifyBackupCode = async ({ user, backupCode }) => {
: codeObj,
);
// Update the user record with the marked backup code.
await User.updateUser(user._id, { backupCodes: updatedBackupCodes });
await updateUser(user._id, { backupCodes: updatedBackupCodes });
return true;
}
return false;