Skip to content

Commit

Permalink
logout route and function
Browse files Browse the repository at this point in the history
Relates #9
  • Loading branch information
rinoma committed Oct 13, 2017
1 parent 4f9ad9f commit 37a3823
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const createevent = require('./createevent')
const verifycharityemail = require('./verifyCharityEmail')
const applyForTickets = require('./applyForTickets')
const applyTicketsSubmit = require('./applyTicketsSubmit')
const logout = require('./logout')

router.get('/', home)
router.get('/login', loginPage)
Expand All @@ -29,6 +30,7 @@ router.post('/event/:eventTitle/tickets', applyTicketsSubmit)
router.get('/rejectcharitysignup/:userinfo', rejectcharitysignup)
router.get('/verifycharityemail/:userinfo', verifycharityemail)
router.post('/event/:eventTitle/applyfortickets', applyForTickets)
router.get('/logout', logout)
router.use(error.client)
router.use(error.server)

Expand Down
4 changes: 4 additions & 0 deletions src/routes/logout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = (req, res) => {
req.session = null
res.redirect('/')
}
4 changes: 4 additions & 0 deletions src/views/partials/navbar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
<li class="pv2 pl2"><a class="link white" href="/sign-up">REGISTER AS A CHARITY</a></li>
{{/unless}}

{{#if session.userId}}
<li class="pv2 pl2"><a class="link white" href="/logout">LOGOUT</a></li>
{{/if}}

{{#if session.isAdmin}}
<li class="pv2 pl2"><a class="link white" href="/addevent">CREATE EVENT</a></li>
{{/if}}
Expand Down

0 comments on commit 37a3823

Please sign in to comment.