From 56b06b5ee36ed83fc44d0775b6218aa8fed85b5e Mon Sep 17 00:00:00 2001 From: jw255 Date: Tue, 10 Apr 2018 21:29:15 +0100 Subject: fixed auth tests --- src/auth.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/auth.ts') diff --git a/src/auth.ts b/src/auth.ts index 8a6b248..14e1170 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -193,8 +193,8 @@ export const unauthorisedErr: Errorware = if (isUnauthorizedError(err)) { return next(new RequestError( err.status, - err.code, - err.message + 'not_authorised', + 'user does not have correct authorisation for task' )); } next(err); @@ -210,7 +210,8 @@ export const unauthorisedErr: Errorware = */ export const isAdmin: Middleware = (req: Request, res: Response, next: NextFunction): void => { - const admin: boolean = req.user.object.userGroups + // tslint:disable-next-line:no-non-null-assertion + const admin: boolean = req!.user!.object!.userGroups! .some((x: UserGroup): boolean => x.name === 'admin'); if (!admin) { -- cgit v1.2.1