add log out

This commit is contained in:
biglyderv 2025-02-25 19:51:46 -05:00
parent 8d0c02e27e
commit d4d2303796
Signed by: biglyderv
GPG key ID: 0E2EB0B4CD7397B5
2 changed files with 20 additions and 0 deletions

View file

@ -1,6 +1,8 @@
import { Router } from "express"; import { Router } from "express";
const router = Router(); const router = Router();
//todo: fix jank
router.get('/login', (req, res, next) => { router.get('/login', (req, res, next) => {
res.ctx.mainPage = 'form' res.ctx.mainPage = 'form'
res.ctx.mainCtx = { res.ctx.mainCtx = {
@ -25,6 +27,18 @@ router.get('/login', (req, res, next) => {
next(); next();
}) })
router.get('/logout', (req, res, next) => {
res.ctx.mainPage = 'form'
res.ctx.mainCtx = {
title: "Log out",
message: 'Are you sure?',
action: "/api/form/you/logout",
inputs: []
}
next();
})
router.get('/new', (req, res, next) => { router.get('/new', (req, res, next) => {
res.ctx.mainPage = 'form' res.ctx.mainPage = 'form'
res.ctx.mainCtx = { res.ctx.mainCtx = {

View file

@ -14,6 +14,12 @@ function legalName(user) {
return user.search(/[^A-Za-z0-9\-\_]/g) == -1; return user.search(/[^A-Za-z0-9\-\_]/g) == -1;
} }
router.post('/logout', (req, res, next) => {
res.clearCookie('token');
apiStat(res, next, `Goodbye!`, '/');
return;
});
async function login(req, res, next) { async function login(req, res, next) {
let { user, pass } = req.body; let { user, pass } = req.body;