diff --git a/middlewares/auth.middleware.js b/middlewares/auth.middleware.js index 1ac8b34..1912e77 100644 --- a/middlewares/auth.middleware.js +++ b/middlewares/auth.middleware.js @@ -26,6 +26,18 @@ module.exports = function (options) { return req.url.split('?')[0] === exc }) + if (process.env.NS_NOUSER) { + req.session = { + user: { + id: 21323 + }, + sessionID: sessionID || 111111111111111111, + isException: false + } + next() + return + } + // FIXME Allowing all urls with _next in it, but not in params if (req.url.split('?')[0].includes('_next') || req.url.split('?')[0].includes('well-known/acme-challenge')) { req.session = { isException: true } diff --git a/modules.json b/modules.json index b268626..f376873 100644 --- a/modules.json +++ b/modules.json @@ -30,8 +30,7 @@ ], "name": "api", "urls": [ - "api.frylabs.net", - "localhost" + "api.frylabs.net" ] }, "main": { diff --git a/modules/api/api.js b/modules/api/api.js index 19889a8..57e82c1 100644 --- a/modules/api/api.js +++ b/modules/api/api.js @@ -391,9 +391,11 @@ function GetApp () { // TODO: cookie age res.cookie('sessionID', sessionID, { domain: '.frylabs.net', // TODO: use url. url: "https://api.frylabs.net" + expires: new Date(new Date().getTime() + (10 * 365 * 24 * 60 * 60 * 1000)), sameSite: 'none' }) res.cookie('sessionID', sessionID, { + expires: new Date(new Date().getTime() + (10 * 365 * 24 * 60 * 60 * 1000)), sameSite: 'none' }) @@ -586,16 +588,16 @@ function GetApp () { // automatically saves to dataFile every n write // FIXME: req.body.datatoadd is for backwards compatibility, remove this sometime in the future - let result = actions.ProcessIncomingRequest( + actions.ProcessIncomingRequest( req.body.datatoadd || req.body, data, { motd, version }, dryRun - ) - - res.json({ - success: result !== -1, - newQuestions: result + ).then((res) => { + res.json({ + success: res !== -1, + newQuestions: res + }) }) })