add log out
This commit is contained in:
parent
8d0c02e27e
commit
d4d2303796
2 changed files with 20 additions and 0 deletions
|
@ -1,6 +1,8 @@
|
|||
import { Router } from "express";
|
||||
const router = Router();
|
||||
|
||||
//todo: fix jank
|
||||
|
||||
router.get('/login', (req, res, next) => {
|
||||
res.ctx.mainPage = 'form'
|
||||
res.ctx.mainCtx = {
|
||||
|
@ -25,6 +27,18 @@ router.get('/login', (req, res, 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) => {
|
||||
res.ctx.mainPage = 'form'
|
||||
res.ctx.mainCtx = {
|
||||
|
|
|
@ -14,6 +14,12 @@ function legalName(user) {
|
|||
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) {
|
||||
let { user, pass } = req.body;
|
||||
|
||||
|
|
Loading…
Reference in a new issue