Skip to content

Commit

Permalink
fix: Emit password recovery event from verifyOtp when otp type is rec…
Browse files Browse the repository at this point in the history
…overy (#829)

## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

Currently when the user goes through the password recovery flow via OTP
and calls the `verifyOtp()` method, the `SIGNED_IN` auth event is
emitted instead of `PASSWORD_RECOVERY` event.

## What is the new behavior?

When the user goes through the password recovery flow using email OTP,
the `PASSWORD_RECOVERY` event is emitted.

## Additional context

A Flutter SDK user reported this, and thought it probably makes sense to
bring it to the JS client as well.
supabase/supabase-flutter#774
  • Loading branch information
dshukertjr committed Dec 29, 2023
1 parent b664f0f commit 78abe52
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/GoTrueClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,10 @@ export default class GoTrueClient {

if (session?.access_token) {
await this._saveSession(session as Session)
await this._notifyAllSubscribers('SIGNED_IN', session)
await this._notifyAllSubscribers(
params.type == 'recovery' ? 'PASSWORD_RECOVERY' : 'SIGNED_IN',
session
)
}

return { data: { user, session }, error: null }
Expand Down

0 comments on commit 78abe52

Please sign in to comment.