mirror of
https://github.com/sasjs/server.git
synced 2025-12-11 03:34:35 +00:00
chore(merge): Merge branch 'master' into authentication-with-jwt
This commit is contained in:
9
api/src/middlewares/verifyAdminIfNeeded.ts
Normal file
9
api/src/middlewares/verifyAdminIfNeeded.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export const verifyAdminIfNeeded = (req: any, res: any, next: any) => {
|
||||
const { user } = req
|
||||
const userId = parseInt(req.params.userId)
|
||||
|
||||
if (!user.isAdmin && user.userId !== userId) {
|
||||
return res.status(401).send('Admin account required')
|
||||
}
|
||||
next()
|
||||
}
|
||||
Reference in New Issue
Block a user