Skip to content

Commit

Permalink
Merge pull request #71 from GSG-G8/20-logout
Browse files Browse the repository at this point in the history
Logout route
  • Loading branch information
ranasobeid95 authored Apr 4, 2020
2 parents d951cc5 + b5c5e00 commit 068be41
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const express = require('express');
const compression = require('compression');
const cookieParser = require('cookie-parser');
const { join } = require('path');

const controller = require('./controllers');
Expand All @@ -14,6 +15,8 @@ app.set('port', process.env.PORT || 5000);

app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());

app.use('/api/v1/', controller);

app.use(express.static(join(__dirname, '..', 'client', 'build')));
Expand Down
2 changes: 2 additions & 0 deletions server/controllers/routes/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
getCohortProjects,
} = require('./project');
const getStats = require('./stats');
const logout = require('./logout');

router.post('/cohorts', addCohort);

Expand All @@ -34,5 +35,6 @@ router.delete('/alumni/:studentId', deleteStudent);
router.put('/alumni/:studentId', putStudentData);
router.delete('/projects/:projectId', deleteProjectData);
router.get('/stats', getStats);
router.get('/logout', logout);

module.exports = router;
6 changes: 6 additions & 0 deletions server/controllers/routes/admin/logout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const logout = (req, res) => {
res.clearCookie('token');
res.json({ statusCode: 200 });
};

module.exports = logout;

0 comments on commit 068be41

Please sign in to comment.