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

Option keepSessionInfo: 'true' does not work. #87

Closed
unitydevadtest opened this issue Apr 26, 2024 · 1 comment
Closed

Option keepSessionInfo: 'true' does not work. #87

unitydevadtest opened this issue Apr 26, 2024 · 1 comment

Comments

@unitydevadtest
Copy link

unitydevadtest commented Apr 26, 2024

Until I implement better solution I still keep returnTo in session to return user to the page where he initiated login. This is possible with keepSessionInfo: 'true' option, it works with google and facebook but not with apple. After apple callback session is just deleted.

Is there any way to fix it?

jaredhanson/passport#919

@autopulated
Copy link
Contributor

You can pass a redirection URL through the state (https://developer.apple.com/documentation/sign_in_with_apple/clientconfigi/3230956-state).

e.g.

// in auth route:
passport.authenticate('apple', { state:JSON.stringify(state), nonce:nonce })(req,res,next);

// passport callback:
passport.use(
    'apple',
    new AppleStrategy({ ....  }, (req, accessToken, refreshToken, profile, done) => {
        let state = {};
        try {
            state = JSON.parse(req.body.state);
        } catch (e) {
            console.error('ignoring un-parseable apple sign-in state', e);
        }

        // state.redirectTo is your redirection URL, but it might have been
        // modified by the user (and is visible to them) so don't put secrets
        // in it or trust its value to be secure!

        // ... the rest of your sign-in logic ...
}))

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

No branches or pull requests

2 participants