mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 02:24:16 +00:00
use validation session as req.session
value
This commit is contained in:
parent
35ab240315
commit
61eceb521c
@ -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 })
|
||||
|
||||
|
@ -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
|
||||
}
|
@ -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
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user