Skip to content

Commit

Permalink
fix: remove phone mfa deletion, match on error codes (#963)
Browse files Browse the repository at this point in the history
## What kind of change does this PR introduce?

Addresses a few existing TODOs

- Remove the deletion of  TOTP object for backward compatibility
- Matches on identity linking error codes instead of messages
  • Loading branch information
J0 committed Sep 27, 2024
1 parent 9d23c3d commit ef3911c
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,8 @@ export default class GoTrueClient {
if (error) {
this._debug('#_initialize()', 'error detecting session from URL', error)

// hacky workaround to keep the existing session if there's an error returned from identity linking
// TODO: once error codes are ready, we should match against it instead of the message
if (
error?.message === 'Identity is already linked' ||
error?.message === 'Identity is already linked to another user'
error?.code === 'identity_already_exists'
) {
return { error }
}
Expand Down Expand Up @@ -2388,11 +2385,6 @@ export default class GoTrueClient {
return { data: null, error }
}

// TODO: Remove once: https://github.com/supabase/auth/pull/1717 is deployed
if (params.factorType === 'phone') {
delete data.totp
}

if (params.factorType === 'totp' && data?.totp?.qr_code) {
data.totp.qr_code = `data:image/svg+xml;utf-8,${data.totp.qr_code}`
}
Expand Down

0 comments on commit ef3911c

Please sign in to comment.