mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 18:44:16 +00:00
fix onlyAdmin
middleware
This commit is contained in:
parent
5206c5aef0
commit
4b062d00e5
@ -1,8 +1,10 @@
|
|||||||
export default (req, res, next) => {
|
export default async (req, res, next) => {
|
||||||
if (!req.auth) {
|
if (!req.auth) {
|
||||||
return res.status(401).json({ error: "No authenticated" })
|
return res.status(401).json({ error: "No authenticated" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
req.auth.user = await req.auth.user()
|
||||||
|
|
||||||
if (!req.auth.user.roles.includes("admin")) {
|
if (!req.auth.user.roles.includes("admin")) {
|
||||||
return res.status(403).json({ error: "To make this request it is necessary to have administrator permissions" })
|
return res.status(403).json({ error: "To make this request it is necessary to have administrator permissions" })
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user