20230124092607_clear_old_2fa_setup.js 649 B

123456789101112131415161718192021222324252627282930
  1. const { batchedUpdate } = require('../scripts/helpers/batchedUpdate')
  2. exports.tags = ['saas']
  3. const batchedUpdateOptions = {
  4. VERBOSE_LOGGING: 'true',
  5. BATCH_SIZE: '1',
  6. }
  7. exports.migrate = async () => {
  8. await batchedUpdate(
  9. 'users',
  10. { 'twoFactorAuthentication.secret': { $exists: true } },
  11. { $unset: { twoFactorAuthentication: true } },
  12. null,
  13. null,
  14. batchedUpdateOptions
  15. )
  16. }
  17. exports.rollback = async () => {
  18. await batchedUpdate(
  19. 'users',
  20. { 'twoFactorAuthentication.secretEncrypted': { $exists: true } },
  21. { $unset: { twoFactorAuthentication: true } },
  22. null,
  23. null,
  24. batchedUpdateOptions
  25. )
  26. }