From bc35891ca7e67d4c7cc8f13113835a575394259d Mon Sep 17 00:00:00 2001 From: biglyderv Date: Mon, 25 Nov 2024 14:12:44 -0500 Subject: [PATCH] add redir field --- client/login.js | 2 +- form/login.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/login.js b/client/login.js index f761b46..f73191a 100644 --- a/client/login.js +++ b/client/login.js @@ -7,7 +7,7 @@ let main = new Route([auth], async function (req, res, input) { return res.render('form', { data: [ { label: "Username", type: "text", name: "user" }, - { label: "Password", type: "password", name: "pass" } + { label: "Password", type: "password", name: "pass" }, ], 'route': '/api/form/login', 'title': 'Login', diff --git a/form/login.js b/form/login.js index 5307253..3e9df62 100644 --- a/form/login.js +++ b/form/login.js @@ -8,7 +8,7 @@ let db = await initDb(); // TODO: rewrite let main = new Route([], async function (req, res, input) { - let { user, pass } = req.body; + let { user, pass, redir } = req.body; if (!pass || !user) return { 'success': false, 'message': 'Some fields are missing' }; @@ -32,7 +32,7 @@ let main = new Route([], async function (req, res, input) { res.cookie('token',token); - return {'success': true, 'message': 'Log in succeeded', 'redirect': '/', 'data': token}; + return {'success': true, 'message': 'Log in succeeded', 'redirect': redir || '/', 'data': token}; }); export default main; \ No newline at end of file