From 4e7b57db4c1e8c1c72a191312e4f95929ebf1bec Mon Sep 17 00:00:00 2001 From: Cadence Ember Date: Sat, 9 Jan 2021 01:49:22 +1300 Subject: [PATCH] Fix new session creation --- api/formapi.js | 2 +- utils/getuser.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/api/formapi.js b/api/formapi.js index f48cd77..89c385a 100644 --- a/api/formapi.js +++ b/api/formapi.js @@ -87,7 +87,7 @@ module.exports = [ statusCode: 303, headers: setToken({ location: "/subscriptions" - }, fill[0]), + }, fill[0]).responseHeaders, contentType: "application/json", content: { status: "ok" diff --git a/utils/getuser.js b/utils/getuser.js index 7442281..85dcb82 100644 --- a/utils/getuser.js +++ b/utils/getuser.js @@ -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 {