Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(core): add reset totp debug script #4664

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
Loading