diff options
| author | cjd24 | 2018-04-19 20:48:19 +0100 |
|---|---|---|
| committer | cjd24 | 2018-04-19 20:48:19 +0100 |
| commit | 92e23d37f843e49eda01a4d0ea7ed8005efffdb2 (patch) | |
| tree | 7c08678dfce9bf82eaa4f71f5e23182f8515d386 /src/auth.ts | |
| parent | Added a write of the base teir JSON object, made the images actually write to... (diff) | |
| parent | Merge branch 'trh/gets' into cjd24/conversion (diff) | |
| download | medicine-92e23d37f843e49eda01a4d0ea7ed8005efffdb2.tar.gz medicine-92e23d37f843e49eda01a4d0ea7ed8005efffdb2.zip | |
Merge branch ‘cjd24/conversion’ of https://gitlab.cs.st-andrews.ac.uk/cs3099group-be-4/project-code into cjd24/conversion
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) { |
