Skip to content

Commit

Permalink
chore(core): add reset totp debug script (#4664)
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi authored Nov 27, 2024
1 parent de9dc57 commit 43133ad
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions core/api/src/debug/reset-totp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* how to run:
*
* pnpm tsx src/debug/reset-user-totp.ts <user id>
*
* <user id>: ID of the user whose TOTP needs to be reset
*/

import { Authentication } from "@/app"

import { setupMongoConnection } from "@/services/mongodb"

const main = async () => {
const args = process.argv.slice(-1)
const userId = args[0] as UserId

if (!userId) {
console.error("Error: User ID is required")
return
}

const result = await Authentication.removeTotp({ userId })
if (result instanceof Error) {
console.error("Error:", result)
return
}
console.log(`Successfully reset TOTP for user ${userId}:`, result)
}

setupMongoConnection()
.then(async (mongoose) => {
await main()
if (mongoose) await mongoose.connection.close()
})
.catch((err) => console.log(err))

0 comments on commit 43133ad

Please sign in to comment.