From 9d8577c923cdbcb3598f00d5ea366793b95198ce Mon Sep 17 00:00:00 2001 From: Zuxxied Date: Sat, 19 Oct 2024 15:36:20 -0400 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