diff options
| author | jw255 | 2018-04-10 21:29:15 +0100 |
|---|---|---|
| committer | jw255 | 2018-04-10 21:29:15 +0100 |
| commit | 56b06b5ee36ed83fc44d0775b6218aa8fed85b5e (patch) | |
| tree | e64084829d9d2121606132f9f5c356eb6a4d0d7d /src/auth.ts | |
| parent | Address numerous errors in test suites (diff) | |
| download | medicine-56b06b5ee36ed83fc44d0775b6218aa8fed85b5e.tar.gz medicine-56b06b5ee36ed83fc44d0775b6218aa8fed85b5e.zip | |
fixed auth tests
Diffstat (limited to 'src/auth.ts')
| -rw-r--r-- | src/auth.ts | 7 |
1 files changed, 4 insertions, 3 deletions
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) { |
