diff options
| author | Tom Harley | 2018-04-11 14:13:28 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-04-11 14:13:28 +0100 |
| commit | e9fda66656a1e36e79e26fa46af554c5ccf3f6bc (patch) | |
| tree | 55a663df93771b1c13c44d02451f7e62e765017e /src/auth.ts | |
| parent | WIP: Add support for raw and meta views (diff) | |
| parent | oh god (diff) | |
| download | medicine-e9fda66656a1e36e79e26fa46af554c5ccf3f6bc.tar.gz medicine-e9fda66656a1e36e79e26fa46af554c5ccf3f6bc.zip | |
Merge branch ‘development’ into trh/gets
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) { |
