aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Harley2018-03-07 15:40:49 +0000
committerTom Harley2018-03-07 15:40:49 +0000
commitc8a418113af37cdca5497df788e62493bf947877 (patch)
treeb5531c1715b983d6d7f6a1385e20cca86803317a /src
parentMerge branch 'trh/pm' into development (diff)
parent... (diff)
downloadmedicine-c8a418113af37cdca5497df788e62493bf947877.tar.gz
medicine-c8a418113af37cdca5497df788e62493bf947877.zip

Merge remote-tracking branch ‘origin/testing-middleware’ into development

Diffstat (limited to 'src')
-rw-r--r--src/app.ts2
-rw-r--r--src/auth.ts9
-rw-r--r--src/db/initPostgresDB.ts2
-rw-r--r--src/logger.ts1
4 files changed, 5 insertions, 9 deletions
diff --git a/src/app.ts b/src/app.ts
index bcb29ca..8c55faa 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -4,7 +4,7 @@ import * as expressJwt from 'express-jwt';
import * as logger from 'morgan';
import * as passport from 'passport';
-import { unauthorisedErr, isAdmin, default as authRouter } from './auth';
+import { default as authRouter, unauthorisedErr } from './auth';
import { RequestError, errorHandler } from './errors/errorware';
import FileRouter from './FileRouter';
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;
///////////////////////////////////////////////////
diff --git a/src/db/initPostgresDB.ts b/src/db/initPostgresDB.ts
index eb979f4..b6844d9 100644
--- a/src/db/initPostgresDB.ts
+++ b/src/db/initPostgresDB.ts
@@ -1,6 +1,6 @@
import * as Sequelize from 'sequelize';
const gres: Sequelize.Sequelize = new Sequelize(
- 'postgres://admin:eprprJacR0hBpmWvs5IDJZTnjRAY2gM3tSm0b1af@localhost:5432/be4',
+ 'postgres://admin:eprprJacR0hBpmWvs5IDJZTnjRAY2gM3tSm0b1af@postgres:5432/be4',
{
operatorsAliases : false
}
diff --git a/src/logger.ts b/src/logger.ts
index f598cd5..953a341 100644
--- a/src/logger.ts
+++ b/src/logger.ts
@@ -4,7 +4,6 @@ import * as colors from 'colors/safe';
import * as winston from 'winston';
import { files } from './files';
-import { profiler } from './profiler';
type LogLevel = 'critical' | 'error' | 'warning' | 'security' | 'info';