async login({ body }, res) {
    const user = await User.findOne({ $or: [{ username: body.username }, { email: body.email }] });
    if (!user) {
      return res.status(400).json({ message: "Can't find this user" });
    }

    const correctPw = await user.isCorrectPassword(body.password);

    if (!correctPw) {
      return res.status(400).json({ message: 'Wrong password!' });
    }
    const token = signToken(user);
    res.json({ token, user });
  }
// login a user, sign a token, and send it back to client - LoginForm.js)
login a user, sign a token, and send it back to client - LoginForm.js)
login a user sign a token and send it back to client - LoginForm . js )
async login({ body }, res) {
    const user = await User.findOne({ $or: [{ username: body.username }, { email: body.email }] });
    if (!user) {
      return res.status(400).json({ message: "Can't find this user" });
    }
    const correctPw = await user.isCorrectPassword(body.password);
    if (!correctPw) {
      return res.status(400).json({ message: 'Wrong password!' });
    }
    const token = signToken(user);
    res.json({ token, user });
  }
async login ( { body } , res ) { const user = await User . findOne ( { $or : [ { username : body . username } , { email : body . email } ] } ) ; if ( ! user ) { return res . status ( 400 ) . json ( { message : "Can't find this user" } ) ; } const correctPw = await user . isCorrectPassword ( body . password ) ; if ( ! correctPw ) { return res . status ( 400 ) . json ( { message : 'Wrong password!' } ) ; } const token = signToken ( user ) ; res . json ( { token , user } ) ; }
login a user, sign a token, and send it back to client - LoginForm.js)
login a user sign a token and send it back to client - LoginForm . js )