diff options
| author | Tom Harley | 2018-03-07 15:40:49 +0000 |
|---|---|---|
| committer | Tom Harley | 2018-03-07 15:40:49 +0000 |
| commit | c8a418113af37cdca5497df788e62493bf947877 (patch) | |
| tree | b5531c1715b983d6d7f6a1385e20cca86803317a /src/auth.ts | |
| parent | Merge branch 'trh/pm' into development (diff) | |
| parent | ... (diff) | |
| download | medicine-c8a418113af37cdca5497df788e62493bf947877.tar.gz medicine-c8a418113af37cdca5497df788e62493bf947877.zip | |
Merge remote-tracking branch ‘origin/testing-middleware’ into development
Diffstat (limited to 'src/auth.ts')
| -rw-r--r-- | src/auth.ts | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/auth.ts b/src/auth.ts index 7bc2945..57c375a 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -3,9 +3,9 @@ import { NextFunction, Request, Response, Router } from 'express'; import * as jwt from 'jsonwebtoken'; import * as passport from 'passport'; import { Strategy } from 'passport-local'; +import { default as Project } from './db/model/Project'; import { default as User } from './db/model/User'; import { default as UserGroup } from './db/model/UserGroup'; -import { default as Project } from './db/model/Project'; import { Errorware } from './errors/errorware'; @@ -109,7 +109,6 @@ export class AuthRouter { next(); } - /** * Used to configure Passport to use the custom authentication strategy. */ @@ -157,9 +156,7 @@ export class AuthRouter { */ export const unauthorisedErr: Errorware = (err: Error, req: Request, res: Response, next: NextFunction): void => { - console.log('fffff'); if (err.name === 'UnauthorizedError') { - console.log('efewfwf'); return next(new RequestError( 401, 'not_authorised', 'user does not have correct authorisation for task' @@ -178,7 +175,7 @@ export const unauthorisedErr: Errorware = */ export const isAdmin: any = (req: Request, res: Response, next: NextFunction): void => { - var isAdmin: boolean = req.user.object.userGroups.some((x: UserGroup): boolean => x.name === 'admin'); + let isAdmin: boolean = req.user.object.userGroups.some((x: UserGroup): boolean => x.name === 'admin'); if (!isAdmin) { next(new RequestError( @@ -188,7 +185,7 @@ export const isAdmin: any = return; } next(); -} +}; export default new AuthRouter().router; /////////////////////////////////////////////////// |
