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

fix: PKCE flow not emitting password recovery event #744

Merged
merged 7 commits into from
Dec 4, 2023

Conversation

dshukertjr
Copy link
Member

What kind of change does this PR introduce?

Currently with PKCE flow, passwordRecovery auth event is not emitted for email password reset flow. This PR fixes it.

What is the current behavior?

signIn event is emitted after clicking on the link sent to the email.

What is the new behavior?

passwordRecovery event is emitted after opening the link sent to the email.

Additional context

Fixes #664

@Vinzent03
Copy link
Collaborator

getSessionFromUrl still returns redirectType: null when using pkce despite that we now have the information. I think we should use AuthSessionUrlResponse as return type in exchangeCodeForSession, so that we can return the redirectType in getSessionFromUrl.


final session = authResponse.session;
if (session != null) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got rid of this check for session.

The signature of the return type on the js SDK guarantees that there is a session, so not sure why the js SDK has the check for session there.
https://github.com/supabase/gotrue-js/blob/master/src/GoTrueClient.ts#L534

@dshukertjr
Copy link
Member Author

@Vinzent03
Hopefully it's good now.

if (session == null) {
throw AuthPKCEGrantCodeExchangeError(
'No session found for the auth code.');
}

return AuthSessionUrlResponse(session: session, redirectType: null);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of exchangeCodeForSession can directly be returned. Currently, redirectType is still null.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have caught that one myself. Should be fixed now!

@dshukertjr dshukertjr merged commit 65859bd into next Dec 4, 2023
8 checks passed
@dshukertjr dshukertjr deleted the fix/pkce-password-recovery branch December 4, 2023 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants