Now that we have successfully implemented the login process for a user, let's start building the functionality to log users in to our app.
Setting up the user login
Modifying the User model
To log in users to the app, we will take the following two parameters: the user's email and their password. We will need to query the database to find the record with their given email; so, let's add a method that will extract the user according to the username:
...
const User = mongoose.model('User', UserSchema);
module.exports = User;
module.exports.createUser = (newUser, callback) => {
bcryptjs.genSalt(10, (err, salt) => {
bcryptjs.hash(newUser.password, salt, (error, hash) => {
// store the hashed...