I should be currently logged in, so we'll create a route for our logout. Let's go to routes
and then users.js
. We'll go down to the bottom and say router.get
, and the route is going to be /logout
, which will be users/users/logout/
. We'll pass in req
and res
and then all we need to do to logout is a req.logout
. Then we'll create a message, we'll say req.flash
, and that's going to be a success message and the text for that will just say You are now logged out
. We want to simply redirect, so we need res.redirect
. Now we'll redirect back to the Login
page because the index page or the Members
page we're not going to be able to access that. We'll put some restrictions on that, so this will go to/users/login
:
router.get('/logout', function(req, res){ req.logout(); req.flash('success', 'You are now logged out'); res.redirect('/users/login'); });
Let's save that and let's restart. Now the link you see goes to user's Logout
. So if I click on that it brings us to theLogin...