use validation session as req.session value

This commit is contained in:
SrGooglo 2023-05-19 15:58:26 +00:00
parent 35ab240315
commit 61eceb521c
3 changed files with 5 additions and 14 deletions

View File

@ -17,6 +17,8 @@ function extractBundle(input, output) {
} else {
await fs.promises.rm(input, { recursive: true, force: true })
console.log("Bundle extracted")
return resolve()
}
})
@ -46,8 +48,6 @@ export default async function (req, res) {
return res.status(401).json({ error: "Unauthorized" })
}
console.log("Auth data =>", auth)
// get bundle file
const bb = busboy({ headers: req.headers })

View File

@ -1,5 +1,3 @@
import jwt from "jsonwebtoken"
export default async function (req, res, next) {
// extract authentification header
let auth = req.headers.authorization
@ -11,7 +9,7 @@ export default async function (req, res, next) {
auth = auth.replace("Bearer ", "")
// check if authentification is valid
const validation = await comty.rest.session.validSession(auth).catch((error) => {
const validation = await comty.rest.session.validateToken(auth).catch((error) => {
return {
valid: false,
}
@ -21,14 +19,7 @@ export default async function (req, res, next) {
return res.status(401).json({ error: "Unauthorized" })
}
// decode authentification header
auth = jwt.decode(auth)
if (!auth) {
return res.status(401).json({ error: "Unauthorized" })
}
req.session = auth
req.session = validation.session
return true
}

View File

@ -97,7 +97,7 @@ async function main() {
},
data: formData,
}).catch((error) => {
console.error("🛑 Error while publishing bundle \n\t", error.response.data)
console.error("🛑 Error while publishing bundle \n\t", error.response?.data ?? error)
return false
})