overleaf/services/web/migrations/20230124092607_clear_old_2fa_setup.js
Jakob Ackermann dd906df7b7 Merge pull request #11360 from overleaf/jpa-encrypt-2fa-secret
[web] two-factor-authentication: encrypt the secret in the db

GitOrigin-RevId: 86642e13d917b239012229f685ad0210039a6706
2023-02-17 09:03:44 +00:00

30 lines
649 B
JavaScript

const { batchedUpdate } = require('../scripts/helpers/batchedUpdate')
exports.tags = ['saas']
const batchedUpdateOptions = {
VERBOSE_LOGGING: 'true',
BATCH_SIZE: '1',
}
exports.migrate = async () => {
await batchedUpdate(
'users',
{ 'twoFactorAuthentication.secret': { $exists: true } },
{ $unset: { twoFactorAuthentication: true } },
null,
null,
batchedUpdateOptions
)
}
exports.rollback = async () => {
await batchedUpdate(
'users',
{ 'twoFactorAuthentication.secretEncrypted': { $exists: true } },
{ $unset: { twoFactorAuthentication: true } },
null,
null,
batchedUpdateOptions
)
}