mirror of
https://github.com/matt-fidd/stratos.git
synced 2026-01-01 20:39:28 +00:00
Add logout functionality
This commit is contained in:
@@ -13,6 +13,9 @@ router.get('/', (req, res) => {
|
||||
});
|
||||
|
||||
router.get('/login', (req, res) => {
|
||||
if (req.session.authenticated)
|
||||
return res.redirect('/admin');
|
||||
|
||||
return res.render('login', {
|
||||
title: 'Stratos - Login'
|
||||
});
|
||||
@@ -31,12 +34,22 @@ router.get('/password-reset', (req, res) => {
|
||||
});
|
||||
|
||||
router.get('/logout', (req, res) => {
|
||||
if (!req.session.authenticated)
|
||||
return res.redirect('/login');
|
||||
|
||||
return res.render('logout', {
|
||||
title: 'Stratos - Logout',
|
||||
username: req.session.fullName
|
||||
});
|
||||
});
|
||||
|
||||
router.post('/logout', (req, res) => {
|
||||
if (req.session.authenticated)
|
||||
req.session.destroy();
|
||||
|
||||
return res.redirect('/login');
|
||||
});
|
||||
|
||||
router.post('/register', async (req, res) => {
|
||||
let fields;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user