fix onlyAdmin middleware

This commit is contained in:
SrGooglo 2025-01-25 19:43:28 +00:00
parent 5206c5aef0
commit 4b062d00e5

View File

@ -1,8 +1,10 @@
export default (req, res, next) => {
export default async (req, res, next) => {
if (!req.auth) {
return res.status(401).json({ error: "No authenticated" })
}
req.auth.user = await req.auth.user()
if (!req.auth.user.roles.includes("admin")) {
return res.status(403).json({ error: "To make this request it is necessary to have administrator permissions" })
}