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

Passport authenticate calls request login #9

Open
vijayst opened this issue Nov 24, 2017 · 0 comments
Open

Passport authenticate calls request login #9

vijayst opened this issue Nov 24, 2017 · 0 comments

Comments

@vijayst
Copy link

vijayst commented Nov 24, 2017

In the starter package, I found the below code:

function login({ email, password, req }) {
  return new Promise((resolve, reject) => {
    passport.authenticate('local', (err, user) => {
      if (!user) { reject('Invalid credentials.') }

      req.login(user, () => resolve(user));
    })({ body: { email, password } });
  });
}

The passport documentation suggests that calling authenticate on passport automatically calls login. So, I believe there is no need to call login again.

Note: passport.authenticate() middleware invokes req.login() automatically. This function is primarily used when users sign up, during which req.login() can be invoked to automatically log in the newly registered user.

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