20230124092607_clear_old_2fa_setup.mjs 736 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { db } from './lib/mongodb.mjs'
  2. import { batchedUpdate } from '@overleaf/mongo-utils/batchedUpdate.js'
  3. const tags = ['saas']
  4. const batchedUpdateOptions = {
  5. VERBOSE_LOGGING: 'true',
  6. BATCH_SIZE: '1',
  7. }
  8. const migrate = async () => {
  9. await batchedUpdate(
  10. db.users,
  11. { 'twoFactorAuthentication.secret': { $exists: true } },
  12. { $unset: { twoFactorAuthentication: true } },
  13. null,
  14. null,
  15. batchedUpdateOptions
  16. )
  17. }
  18. const rollback = async () => {
  19. await batchedUpdate(
  20. db.users,
  21. { 'twoFactorAuthentication.secretEncrypted': { $exists: true } },
  22. { $unset: { twoFactorAuthentication: true } },
  23. null,
  24. null,
  25. batchedUpdateOptions
  26. )
  27. }
  28. export default {
  29. tags,
  30. migrate,
  31. rollback,
  32. }