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
})
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 }

View file

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

View file

@ -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
)
).then((res) => {
res.json({
success: result !== -1,
newQuestions: result
success: res !== -1,
newQuestions: res
})
})
})