From ef3911cd1a082a6825ce25fe326081e096bd55f5 Mon Sep 17 00:00:00 2001 From: Joel Lee Date: Fri, 27 Sep 2024 15:08:56 +0200 Subject: [PATCH] fix: remove phone mfa deletion, match on error codes (#963) ## 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 --- src/GoTrueClient.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index c105be617..207675323 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -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 } } @@ -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}` }