Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The event PASSWORD_RECOVERY does not always fire #129

Closed
tequila99 opened this issue Aug 30, 2021 · 2 comments
Closed

The event PASSWORD_RECOVERY does not always fire #129

tequila99 opened this issue Aug 30, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@tequila99
Copy link

When you recover a password, a user application receives two events (SIGN_IN and PASSWORD_RECOVERY) . If the handler of the first event (SIGN_IN) changes window.location.href (a redirect occurs, for example), then the second event (PASSWORD_RECOVERY) does not fire.

There is the code in GoTrueClient.ts:

if (options?.storeSession) {
  this._saveSession(session)
  this._notifyAllSubscribers('SIGNED_IN')
  if (getParameterByName('type') === 'recovery') {
    this._notifyAllSubscribers('PASSWORD_RECOVERY')
  }
}

I suppose the following code (or something similar) can fix this problem

if (options?.storeSession) {
  this._saveSession(session)
  const recoveryMode = getParameterByName('type')
  this._notifyAllSubscribers('SIGNED_IN')
  if (recoveryMode === 'recovery') {
    this._notifyAllSubscribers('PASSWORD_RECOVERY')
  }
}

Thanks

@tequila99 tequila99 added the bug Something isn't working label Aug 30, 2021
awalias added a commit that referenced this issue Sep 27, 2021
@mryechkin
Copy link

I'm running into a similar issue as well, and I'm wondering if this change could help address it. In my mind the SIGN_IN event shouldn't even fire before PASSWORD_RECOVERY (and INIT if that PR is accepted).

Otherwise as you said, if the SIGN_IN event handler does a redirect or something similar, then even if the PASSWORD_RECOVERY event does fire, the app may no longer be in the desired state. Users should be in the Update Password flow, rather than the "Authenticated" state - which is what happens right now in this case.

@awalias
Copy link
Member

awalias commented Nov 18, 2021

fixed here #142

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants