From 5185a02238cc9429ba86896093b8ef22e5ace577 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Minelli?= <michael@minelli.me> Date: Fri, 8 Dec 2023 16:45:45 +0100 Subject: [PATCH] Routes => Fix call of functions from routes --- ExpressAPI/src/routes/AssignmentRoutes.ts | 8 ++++---- ExpressAPI/src/routes/BaseRoutes.ts | 4 ++-- ExpressAPI/src/routes/GitlabRoutes.ts | 2 +- ExpressAPI/src/routes/SessionRoutes.ts | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ExpressAPI/src/routes/AssignmentRoutes.ts b/ExpressAPI/src/routes/AssignmentRoutes.ts index 605bbc4..645104b 100644 --- a/ExpressAPI/src/routes/AssignmentRoutes.ts +++ b/ExpressAPI/src/routes/AssignmentRoutes.ts @@ -46,11 +46,11 @@ class AssignmentRoutes implements RoutesManager { }; registerOnBackend(backend: Express) { - backend.get('/assignments/:assignmentNameOrUrl', SecurityMiddleware.check(true), this.getAssignment); - backend.post('/assignments', SecurityMiddleware.check(true, SecurityCheckType.TEACHING_STAFF), ParamsValidatorMiddleware.validate(this.assignmentValidator), this.createAssignment); + backend.get('/assignments/:assignmentNameOrUrl', SecurityMiddleware.check(true), this.getAssignment.bind(this)); + backend.post('/assignments', SecurityMiddleware.check(true, SecurityCheckType.TEACHING_STAFF), ParamsValidatorMiddleware.validate(this.assignmentValidator), this.createAssignment.bind(this)); - backend.patch('/assignments/:assignmentNameOrUrl/publish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.publishAssignment); - backend.patch('/assignments/:assignmentNameOrUrl/unpublish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.unpublishAssignment); + backend.patch('/assignments/:assignmentNameOrUrl/publish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.publishAssignment.bind(this)); + backend.patch('/assignments/:assignmentNameOrUrl/unpublish', SecurityMiddleware.check(true, SecurityCheckType.ASSIGNMENT_STAFF), this.unpublishAssignment.bind(this)); } // Get an assignment by its name or gitlab url diff --git a/ExpressAPI/src/routes/BaseRoutes.ts b/ExpressAPI/src/routes/BaseRoutes.ts index c0ac80a..474f5bb 100644 --- a/ExpressAPI/src/routes/BaseRoutes.ts +++ b/ExpressAPI/src/routes/BaseRoutes.ts @@ -6,8 +6,8 @@ import RoutesManager from '../express/RoutesManager'; class BaseRoutes implements RoutesManager { registerOnBackend(backend: Express) { - backend.get('/', this.homepage); - backend.get('/health_check', this.healthCheck); + backend.get('/', this.homepage.bind(this)); + backend.get('/health_check', this.healthCheck.bind(this)); } private async homepage(req: express.Request, res: express.Response) { diff --git a/ExpressAPI/src/routes/GitlabRoutes.ts b/ExpressAPI/src/routes/GitlabRoutes.ts index 0090527..2f4affb 100644 --- a/ExpressAPI/src/routes/GitlabRoutes.ts +++ b/ExpressAPI/src/routes/GitlabRoutes.ts @@ -8,7 +8,7 @@ import GitlabManager from '../managers/GitlabManager'; class GitlabRoutes implements RoutesManager { registerOnBackend(backend: Express) { - backend.get('/gitlab/project/:gitlabProjectIdOrNamespace/checkTemplateAccess', SecurityMiddleware.check(true, SecurityCheckType.TEACHING_STAFF), this.checkTemplateAccess); + backend.get('/gitlab/project/:gitlabProjectIdOrNamespace/checkTemplateAccess', SecurityMiddleware.check(true, SecurityCheckType.TEACHING_STAFF), this.checkTemplateAccess.bind(this)); } private async checkTemplateAccess(req: express.Request, res: express.Response) { diff --git a/ExpressAPI/src/routes/SessionRoutes.ts b/ExpressAPI/src/routes/SessionRoutes.ts index a5bd42f..60b630d 100644 --- a/ExpressAPI/src/routes/SessionRoutes.ts +++ b/ExpressAPI/src/routes/SessionRoutes.ts @@ -32,9 +32,9 @@ class SessionRoutes implements RoutesManager { }; registerOnBackend(backend: Express) { - backend.post('/login', ParamsValidatorMiddleware.validate(this.loginValidator), this.login); - backend.post('/refresh_tokens', ParamsValidatorMiddleware.validate(this.refreshTokensValidator), this.refreshTokens); - backend.get('/test_session', SecurityMiddleware.check(true), this.testSession); + backend.post('/login', ParamsValidatorMiddleware.validate(this.loginValidator), this.login.bind(this)); + backend.post('/refresh_tokens', ParamsValidatorMiddleware.validate(this.refreshTokensValidator), this.refreshTokens.bind(this)); + backend.get('/test_session', SecurityMiddleware.check(true), this.testSession.bind(this)); } private async login(req: express.Request, res: express.Response) { -- GitLab