Now that we have completed the implementation of user authentication, we need to configure the application routes to handle the validation and creation of users.
Let's make some changes in the index.js
file inside the routes
folder:
Add the following highlighted code to the
index.js
file:var express = require('express'); var router = express.Router(); var passport = require('passport'); /* GET home page. */ router.get('/', function(req, res) { res.render('index.ejs'); }); module.exports = router;
Note that we set up the default router to render a page called
index.ejs
. We have not created this page yet, but we will do so soon; for now, we will continue setting the necessary routes to handle authentication.Let's create the route for a
profile.ejs
page; place the following code after thehome page
route function:/* GET profile page. */ router.get('/profile', isLoggedIn, function(req, res) { res.render('profile.ejs', { user : req.user }); });
Here, we passed an
isLoggedIn...