mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +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 {
|
} else {
|
||||||
await fs.promises.rm(input, { recursive: true, force: true })
|
await fs.promises.rm(input, { recursive: true, force: true })
|
||||||
|
|
||||||
|
console.log("Bundle extracted")
|
||||||
|
|
||||||
return resolve()
|
return resolve()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -46,8 +48,6 @@ export default async function (req, res) {
|
|||||||
return res.status(401).json({ error: "Unauthorized" })
|
return res.status(401).json({ error: "Unauthorized" })
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Auth data =>", auth)
|
|
||||||
|
|
||||||
// get bundle file
|
// get bundle file
|
||||||
const bb = busboy({ headers: req.headers })
|
const bb = busboy({ headers: req.headers })
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
import jwt from "jsonwebtoken"
|
|
||||||
|
|
||||||
export default async function (req, res, next) {
|
export default async function (req, res, next) {
|
||||||
// extract authentification header
|
// extract authentification header
|
||||||
let auth = req.headers.authorization
|
let auth = req.headers.authorization
|
||||||
@ -11,7 +9,7 @@ export default async function (req, res, next) {
|
|||||||
auth = auth.replace("Bearer ", "")
|
auth = auth.replace("Bearer ", "")
|
||||||
|
|
||||||
// check if authentification is valid
|
// 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 {
|
return {
|
||||||
valid: false,
|
valid: false,
|
||||||
}
|
}
|
||||||
@ -21,14 +19,7 @@ export default async function (req, res, next) {
|
|||||||
return res.status(401).json({ error: "Unauthorized" })
|
return res.status(401).json({ error: "Unauthorized" })
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode authentification header
|
req.session = validation.session
|
||||||
auth = jwt.decode(auth)
|
|
||||||
|
|
||||||
if (!auth) {
|
|
||||||
return res.status(401).json({ error: "Unauthorized" })
|
|
||||||
}
|
|
||||||
|
|
||||||
req.session = auth
|
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
@ -97,7 +97,7 @@ async function main() {
|
|||||||
},
|
},
|
||||||
data: formData,
|
data: formData,
|
||||||
}).catch((error) => {
|
}).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
|
return false
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user