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

Cannot return an error in the callback #27

Closed
ItalyPaleAle opened this issue Mar 28, 2015 · 1 comment
Closed

Cannot return an error in the callback #27

ItalyPaleAle opened this issue Mar 28, 2015 · 1 comment

Comments

@ItalyPaleAle
Copy link

See this code:

    passport.use(new GoogleStrategy(strategyOpts,
        function(accessToken, refreshToken, profile, done) {
            // Check that the hosted domain is correct
            let profileObj = profile || {}
            let profileArgs = profile._json || {}
            if(!profileArgs || !profileArgs.domain || profileArgs.domain != config.google.hostedDomain) {
                return done('An error', null)
            }

            return done(null, profile)
        })
    )

When passing an error to the done callback (first argument), the page doesn't finish loading.

@rkusa
Copy link
Owner

rkusa commented Mar 30, 2015

I think this is not directly related to koa-passport. Anyway, you can fix your code by returning an actual error:

return done(new Error('An error'), null)

@rkusa rkusa closed this as completed Sep 28, 2015
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