Fix new session creation

This commit is contained in:
Cadence Ember 2021-01-09 01:49:22 +13:00
parent c15f83f899
commit 4e7b57db4c
No known key found for this signature in database
GPG Key ID: BC1C2C61CF521B17
2 changed files with 3 additions and 3 deletions

View File

@ -87,7 +87,7 @@ module.exports = [
statusCode: 303,
headers: setToken({
location: "/subscriptions"
}, fill[0]),
}, fill[0]).responseHeaders,
contentType: "application/json",
content: {
status: "ok"

View File

@ -9,7 +9,7 @@ function getToken(req, responseHeaders) {
let token = cookie.token
if (!token) {
if (responseHeaders) { // we should create a token
setToken(responseHeaders)
token = setToken(responseHeaders).token
} else {
return null
}
@ -23,7 +23,7 @@ function setToken(responseHeaders, token) {
if (!token) token = crypto.randomBytes(18).toString("base64").replace(/\W/g, "_")
setCookie.push(`token=${token}; Path=/; Max-Age=2147483648; HttpOnly; SameSite=Lax`)
responseHeaders["set-cookie"] = setCookie
return responseHeaders
return {token, responseHeaders}
}
class User {