supertokens / supertokens-auth-react

ReactJS authentication module for SuperTokens
https://supertokens.com
Other
285 stars 88 forks source link

Redirection callback hook, getRedirectionURL(context) never called with context.isNewUser === true #315

Closed slrobertson1 closed 3 years ago

slrobertson1 commented 3 years ago

Context

Following the example for detecting when a newly created user account has logged in for the first time in order to redirect the user to an onboarding route, context.isNewUser is always false. https://supertokens.io/docs/emailpassword/advanced-customizations/frontend-hooks/redirection-callback

I am using supertokens-core 3.5 and supertokens-auth-react 0.15.5

Problem

After a new user has successfully signed up and verified their email address, I need to redirect them to an onboarding route where I collect demographic data. Upon clicking on the email verification link and then clicking 'Continue' on the 'Email verification successful!' pop-up, the getRedirectionURL callback is called with context.action === "SUCCESS", but context.isNewUser === false, so I am not able to detect when a new user logs in for the first time.

How to Reproduce

I am using the following example callback:

SuperTokens.init({
    appInfo: {...},
    recipeList: [
        EmailPassword.init({
            getRedirectionURL: async (context) => {
                if (context.action === "SUCCESS" && context.isNewUser) {
                    if (context.redirectToPath !== undefined) {
                        // we are navigating back to where the user was before they authenticated
                        return context.redirectToPath;
                    }
                    return "/dashboard";
                }
                return undefined;
            }
        }),
        Session.init()
    ]
});
rishabhpoddar commented 3 years ago

@slrobertson1 this has been fixed and released in version 0.15.6. You simply need to update the SDK.