aboutsummaryrefslogtreecommitdiff
path: root/src/app.ts
diff options
context:
space:
mode:
authorTom Harley2018-03-29 08:32:54 +0100
committerTom Harley2018-03-29 08:32:54 +0100
commit8f39a1403d3c94f3d51693e41843750352408cba (patch)
tree4833fd458e1d8590d798b8d1ede14bfb487aadea /src/app.ts
parentMerge branch 'testing-middleware' into development (diff)
downloadmedicine-8f39a1403d3c94f3d51693e41843750352408cba.tar.gz
medicine-8f39a1403d3c94f3d51693e41843750352408cba.zip

Address numerous errors in test suites

Many errors still remian.

Diffstat (limited to 'src/app.ts')
-rw-r--r--src/app.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/app.ts b/src/app.ts
index ad00105..c627027 100644
--- a/src/app.ts
+++ b/src/app.ts
@@ -12,6 +12,7 @@ import FileRouter from './FileRouter';
import { default as File } from './db/model/File';
import { default as Project } from './db/model/Project';
import { default as User } from './db/model/User';
+import { default as UserGroup } from './db/model/UserGroup';
/**
* Configuration of the Express server app, including installation of
@@ -67,6 +68,21 @@ class App {
] })
);
this.express.use(passport.initialize());
+ this.express.use(async(
+ req: ex.Request, res: ex.Response, next: ex.NextFunction
+ ): Promise<void> => {
+ if (req.user != null) {
+ req.user = await User.findOne({
+ where: {
+ username: req.user.object.username
+ },
+ include: [
+ UserGroup
+ ]
+ });
+ }
+ next();
+ });
if (this.logEnabled) {
this.express.use(logger('combined'));
}