diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/FileRouter.ts | 3 | ||||
| -rw-r--r-- | src/app.ts | 1 | ||||
| -rw-r--r-- | src/db/model/UserGroup.ts | 3 | ||||
| -rw-r--r-- | src/index.ts | 20 |
4 files changed, 24 insertions, 3 deletions
diff --git a/src/FileRouter.ts b/src/FileRouter.ts index bbcc0f2..b750094 100644 --- a/src/FileRouter.ts +++ b/src/FileRouter.ts @@ -617,6 +617,7 @@ export class FileRouter { ): Promise<void> => { logger.debug(`Searching for user ${name}`); const user: User | null = await User.findOne({ + include: [{all: true}], where: { username: name } @@ -637,7 +638,6 @@ export class FileRouter { req: Request, res: Response, next: NextFunction, projectName: string ): Promise<void> => { - logger.debug(`Searching for project ${projectName}`); res.locals.project = await Project.findOne({ where: { name: projectName @@ -708,6 +708,7 @@ export class FileRouter { ): Promise<void> => { logger.debug(`Searching for file ${fileId}`); const file: File | null = await File.findOne({ + include: [{all: true}], where: { uuid: fileId } @@ -75,6 +75,7 @@ class App { logger.debug('Loading basic middleware'); 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 @@ -38,6 +38,9 @@ export default class UserGroup extends Model<UserGroup> { public canEditProjects!: boolean; @Column + public canAccessLogs!: boolean; + + @Column public isInternal!: boolean; @AllowNull 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) { |
