Skip to content

Commit

Permalink
changed admin unauthorized response
Browse files Browse the repository at this point in the history
  • Loading branch information
RA341 committed Nov 12, 2024
1 parent e177652 commit da9d955
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions devU-api/src/entities/user/user.middlware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import UserService from './user.service'
export async function isAdmin(req: Request, res: Response, next: NextFunction) {
const userId = req.currentUser?.userId
if (!userId) {
return res.status(403).send('Unauthorized')
return res.status(403).json({ 'error': 'Unauthorized' })
}

const isAdmin = await UserService.isAdmin(userId)
if (!isAdmin!.isAdmin!) return res.status(403).send('unauthorized')
if (!isAdmin!.isAdmin!) return res.status(403).json({ "error": 'Unauthorized' })

next()
}

0 comments on commit da9d955

Please sign in to comment.