add redir field
This commit is contained in:
parent
ef34429dfa
commit
bc35891ca7
2 changed files with 3 additions and 3 deletions
|
@ -7,7 +7,7 @@ let main = new Route([auth], async function (req, res, input) {
|
||||||
return res.render('form', {
|
return res.render('form', {
|
||||||
data: [
|
data: [
|
||||||
{ label: "Username", type: "text", name: "user" },
|
{ label: "Username", type: "text", name: "user" },
|
||||||
{ label: "Password", type: "password", name: "pass" }
|
{ label: "Password", type: "password", name: "pass" },
|
||||||
],
|
],
|
||||||
'route': '/api/form/login',
|
'route': '/api/form/login',
|
||||||
'title': 'Login',
|
'title': 'Login',
|
||||||
|
|
|
@ -8,7 +8,7 @@ let db = await initDb();
|
||||||
|
|
||||||
// TODO: rewrite
|
// TODO: rewrite
|
||||||
let main = new Route([], async function (req, res, input) {
|
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' };
|
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);
|
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;
|
export default main;
|
Loading…
Reference in a new issue