mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2024-11-22 15:47:30 +00:00
Fix new session creation
This commit is contained in:
parent
c15f83f899
commit
4e7b57db4c
@ -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"
|
||||||
|
@ -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 {
|
||||||
|
Loading…
Reference in New Issue
Block a user