Back End Setup

1. Create Mongoose User model

api/models/Users.js
var Mongoose = require('mongoose');
var Schema = Mongoose.Schema;

// Create Schema Object
var UserSchema = new Schema({ 
    firstName: { type: String }, 
    lastName: { type: String }, 
    username: { type: String, default: '' }, 
    email: { type: String }, 
    password: { type: String }, 
    resetToken: { type: String }, 
    resetTokenExpires: { type: Date }, 
    status: { type: Boolean, default: true }, 
    googleId: { type: String }, 
    profileImage: { type: String, default: '' }
});

// This will creates database collection named "Users" in the Database
var Users = Mongoose.model('Users', UserSchema);

module.exports = Users;

2. Set up API route, ensuring compatibility with passportJS

Register requires a passport.authenticate function, along with any route in which the username/password needs to be explicitly checked against.

For any routes that just needs to check whether the user is logged in, it can just use passportJS isAuthenticated().

3. Testing With Postman

Use Postman App to test the backend routes.

Postman Testing

Last updated