From 6434b4dfce2da307d66ec5670d570d66ea8af8f8 Mon Sep 17 00:00:00 2001 From: Nicolai Ort Date: Thu, 21 Jan 2021 18:12:53 +0100 Subject: [PATCH] Added check for empty token for runner self-service get ref #112 --- src/controllers/RunnerSelfServiceController.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/controllers/RunnerSelfServiceController.ts b/src/controllers/RunnerSelfServiceController.ts index 88de8f5..5ca8311 100644 --- a/src/controllers/RunnerSelfServiceController.ts +++ b/src/controllers/RunnerSelfServiceController.ts @@ -3,7 +3,7 @@ import { Body, Get, JsonController, OnUndefined, Param, Post } from 'routing-con import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi'; import { getConnectionManager, Repository } from 'typeorm'; import { config } from '../config'; -import { InvalidCredentialsError } from '../errors/AuthError'; +import { InvalidCredentialsError, JwtNotProvidedError } from '../errors/AuthError'; import { RunnerEmailNeededError, RunnerNotFoundError } from '../errors/RunnerErrors'; import { RunnerGroupNotFoundError } from '../errors/RunnerGroupErrors'; import { RunnerOrganisationNotFoundError } from '../errors/RunnerOrganisationErrors'; @@ -69,6 +69,7 @@ export class RunnerSelfServiceController { * @param token The runner jwt provided by the runner to identitfy themselves. */ private async getRunner(token: string): Promise { + if (token == "") { throw new JwtNotProvidedError(); } let jwtPayload = undefined try { jwtPayload = jwt.verify(token, config.jwt_secret);