1

I knew on GraphQL. Now I want to add user authentication using passport-local-mongoose with passport.js.

But response don't have graphql. How to solve this. Here is my solution, but this doesn't work get error: TypeError: res.end is not a function :

login: async ({ email, password }, req, res) => {
    const user = new User({
      email,
      password
    })
    req.login(user, function (err) {
      if (err) {
        console.log(err)
      } else {
        passport.authenticate('local')(req, function (err) {
          throw err
        })
      }
    })
    console.log(req.user)
    return req.user
  }

How to solve this problem or how to authentication using passport.js ?

Ken White
  • 123,280
  • 14
  • 225
  • 444
feruz00
  • 53
  • 7

0 Answers0