Merge branch 'master' of gitlab.com:MrFry/mrfrys-node-server into master

This commit is contained in:
MrFry 2020-08-30 09:55:54 +02:00
commit 72470d0366
3 changed files with 21 additions and 8 deletions

View file

@ -26,6 +26,18 @@ module.exports = function (options) {
return req.url.split('?')[0] === exc 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 // 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')) { if (req.url.split('?')[0].includes('_next') || req.url.split('?')[0].includes('well-known/acme-challenge')) {
req.session = { isException: true } req.session = { isException: true }

View file

@ -30,8 +30,7 @@
], ],
"name": "api", "name": "api",
"urls": [ "urls": [
"api.frylabs.net", "api.frylabs.net"
"localhost"
] ]
}, },
"main": { "main": {

View file

@ -391,9 +391,11 @@ function GetApp () {
// TODO: cookie age // TODO: cookie age
res.cookie('sessionID', sessionID, { res.cookie('sessionID', sessionID, {
domain: '.frylabs.net', // TODO: use url. url: "https://api.frylabs.net" 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' sameSite: 'none'
}) })
res.cookie('sessionID', sessionID, { res.cookie('sessionID', sessionID, {
expires: new Date(new Date().getTime() + (10 * 365 * 24 * 60 * 60 * 1000)),
sameSite: 'none' sameSite: 'none'
}) })
@ -586,16 +588,16 @@ function GetApp () {
// automatically saves to dataFile every n write // automatically saves to dataFile every n write
// FIXME: req.body.datatoadd is for backwards compatibility, remove this sometime in the future // 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, req.body.datatoadd || req.body,
data, data,
{ motd, version }, { motd, version },
dryRun dryRun
) ).then((res) => {
res.json({ res.json({
success: result !== -1, success: res !== -1,
newQuestions: result newQuestions: res
})
}) })
}) })