Demo, all content is generated
Question

User lost their phone and is locked out by 2FA, how do I reset it?

Open · 191 views · asked by wendy_l · edited

First 2FA support ticket. User got a new phone, didn't transfer the authenticator app, can't log in. I can see the factor in the Supabase dashboard but I don't see a 'remove factor' button. How do people normally handle this? And how do I know it's really them asking?

What I’ve tried

Looked through the Auth user page in the dashboard. Found auth.mfa_factors table in the SQL editor but I'm scared to delete from auth tables directly.

Comment
Supabase or your own auth? kofi_mensah · edited
Supabase wendy_l · edited

2 answers

kofi_mensah · edited

Server-side with the service role key you can remove the factor:

const { data } = await admin.auth.admin.mfa.listFactors({ userId })
await admin.auth.admin.mfa.deleteFactor({ id: data.factors[0].id, userId })

Run it from a script or a protected admin action, not from the client. After that they log in with just the password and can enroll the new phone.

The identity question is the harder part. Minimum: the request must come from the account's email address, and send a confirmation to that address before you reset.

Comment
Thanks, the admin API is what I was looking for. Still thinking about the identity part. wendy_l · edited
amir_h · edited

For the future: Supabase has no built-in backup codes. Common workarounds are letting users enroll two TOTP factors (phone + a second device or password manager), or building your own backup codes stored hashed. Also mention during enrollment that a new phone means re-enrolling.

On identity: an email check proves they control the mailbox, which is the same thing a password reset proves. If your app holds sensitive data, add a waiting period (e.g. 24h, notify the account) before the factor is removed. That stops a mailbox takeover from also becoming a 2FA takeover instantly.

Comment