aboutsummaryrefslogtreecommitdiff
path: root/src/auth.ts
diff options
context:
space:
mode:
authorTom Harley2018-04-11 14:13:28 +0100
committerTom Harley2018-04-11 14:13:28 +0100
commite9fda66656a1e36e79e26fa46af554c5ccf3f6bc (patch)
tree55a663df93771b1c13c44d02451f7e62e765017e /src/auth.ts
parentWIP: Add support for raw and meta views (diff)
parentoh god (diff)
downloadmedicine-e9fda66656a1e36e79e26fa46af554c5ccf3f6bc.tar.gz
medicine-e9fda66656a1e36e79e26fa46af554c5ccf3f6bc.zip

Merge branch ‘development’ into trh/gets

Diffstat (limited to 'src/auth.ts')
-rw-r--r--src/auth.ts7
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) {