Added check for empty token for runner self-service get

ref #112
This commit is contained in:
Nicolai Ort 2021-01-21 18:12:53 +01:00
parent e964a8ed44
commit 6434b4dfce
1 changed files with 2 additions and 1 deletions

View File

@ -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<Runner> {
if (token == "") { throw new JwtNotProvidedError(); }
let jwtPayload = undefined
try {
jwtPayload = <any>jwt.verify(token, config.jwt_secret);