-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlogoutController.js
More file actions
36 lines (29 loc) · 874 Bytes
/
logoutController.js
File metadata and controls
36 lines (29 loc) · 874 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
defines an object which contains functions executed as callback
when a client requests for `logout` paths in the server
*/
const logoutController = {
/*
executed when the client sends an HTTP GET request `/logout`
as defined in `../routes/routes.js`
*/
getLogOut: function (req, res) {
/*
logs-out the current user
destroys the current values stored in `req.session`
*/
req.session.destroy(function(err) {
if(err) throw err;
/*
redirects the client to `/profile` using HTTP GET,
defined in `../routes/routes.js`
*/
res.redirect('/');
});
}
}
/*
exports the object `logoutController` (defined above)
when another script exports from this file
*/
module.exports = logoutController;