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.
In the starter package, I found the below code:
The passport documentation suggests that calling authenticate on passport automatically calls login. So, I believe there is no need to call login again.