1
0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2024-11-14 12:27:28 +00:00

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, statusCode: 303,
headers: setToken({ headers: setToken({
location: "/subscriptions" location: "/subscriptions"
}, fill[0]), }, fill[0]).responseHeaders,
contentType: "application/json", contentType: "application/json",
content: { content: {
status: "ok" status: "ok"

View File

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