aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/auth.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/auth.ts b/src/auth.ts
index 937f20f..3feac5d 100644
--- a/src/auth.ts
+++ b/src/auth.ts
@@ -83,6 +83,14 @@ export class AuthRouter {
next();
}
+ //middleware to check privileges - admin
+ public isAdmin(req: Request, res: Response, next: NextFunction) {
+ if (!req.user.admin) {
+ next(new RequestError(401, 'not_authorised', 'user is not authorised to perform task'));
+ }
+ next();
+ }
+
// Configure local strategy to use with passport-js.
private configStrategy() {
passport.use(new localStrategy( (username, password, done) => {