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

What to do on done(null, error) #28

Open
MartinGian opened this issue Jul 19, 2018 · 0 comments
Open

What to do on done(null, error) #28

MartinGian opened this issue Jul 19, 2018 · 0 comments

Comments

@MartinGian
Copy link

MartinGian commented Jul 19, 2018

Hi,

Thanks for this awesome library. I am using it in Production, and I have a doubt about what to do when I can't authenticate the user with a given token.

Right now I'm calling done(null, error) but that return the error and render it in the web, and that's not what I want. I want to be able, for example, to clean the user cookie and redirect him to the home page.

How can I do that? Can I have access to the req, res objects inside the Strategy configuration?

passport.use(
  new RememberMeStrategy(
    (token, done) => {
      loginWithHash(token).then(response => {
        if (!response.success) {
            // HERE: instead of doing that, I want to clean the user cookies and redirect to home
             return done(response.error);
        }
        return done(null, response.data);
      });
    },
    (user, done) => done(null, user.hash),
  ),
);

Thanks in advance.

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

1 participant