diff --git a/src/GoTrueClient.ts b/src/GoTrueClient.ts index 94247672c..47349882e 100644 --- a/src/GoTrueClient.ts +++ b/src/GoTrueClient.ts @@ -2545,8 +2545,19 @@ export default class GoTrueClient { let nextLevel: AuthenticatorAssuranceLevels | null = currentLevel + const { + data: { user }, + error: userError, + } = await this._getUser() + if (userError) { + return { data: null, error: userError } + } + if (!user) { + return { data: { currentLevel, nextLevel, currentAuthenticationMethods: [] }, error: null } + } + const verifiedFactors = - session.user.factors?.filter((factor: Factor) => factor.status === 'verified') ?? [] + user.factors?.filter((factor: Factor) => factor.status === 'verified') ?? [] if (verifiedFactors.length > 0) { nextLevel = 'aal2'