From deab81f8ef469c4119838d72b56683b8dd4cbcfe Mon Sep 17 00:00:00 2001 From: jw255 Date: Fri, 13 Apr 2018 16:10:32 +0100 Subject: fixed some privs --- src/FileRouter.ts | 1 + src/app.ts | 1 + src/db/model/UserGroup.ts | 3 +++ src/index.ts | 20 ++++++++++++++++++-- 4 files changed, 23 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/FileRouter.ts b/src/FileRouter.ts index 619be9e..7db7eb2 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -550,6 +550,7 @@ export class FileRouter { name: string ): Promise => { const user: User | null = await User.findOne({ + include: [{all: true}], where: { username: name } diff --git a/src/app.ts b/src/app.ts index d8dfe5d..f71ecf3 100644 --- a/src/app.ts +++ b/src/app.ts @@ -68,6 +68,7 @@ class App { private middleware(): void { this.express.use(expressJwt({secret: 'Mr Secret'}) .unless({path: [ + '/', '/cs3099group-be-4/oauth/token', '/cs3099group-be-4/_supported_protocols_' ] }) diff --git a/src/db/model/UserGroup.ts b/src/db/model/UserGroup.ts index 46945de..60d45c8 100644 --- a/src/db/model/UserGroup.ts +++ b/src/db/model/UserGroup.ts @@ -37,6 +37,9 @@ export default class UserGroup extends Model { @Column public canEditProjects!: boolean; + @Column + public canAccessLogs!: boolean; + @Column public isInternal!: boolean; diff --git a/src/index.ts b/src/index.ts index f172e61..7e21c35 100644 --- a/src/index.ts +++ b/src/index.ts @@ -52,18 +52,34 @@ logger.info(`Port ${port} chosen`); isInternal: false, description: 'Systems admin' }); + const logging: UserGroup = new UserGroup({ + name: 'logging', + canAccessLogs: true, + isInternal: false, + description: 'Allows Post to Log' + }); + await logging.save(); await admin.save(); + logger.info('Adding admin user'); const root: User = new User({ username: 'hafeez', - password: 'pass', - userGroups: [admin] + password: 'pass' }); await root.save(); + await root.$set('userGroups', [admin, logging]); + + const user: User | null = await User.findOne({ + include: [{all: true}], + where: { + username: 'hafeez' + } + }); + logger.info('Booting ExpressJS server'); app.listen(port, (err: Error) => { if (err) { -- cgit v1.2.1