Skip to content

Commit

Permalink
fix: application crash by wrong / missing secret key
Browse files Browse the repository at this point in the history
The middleware tries to end the request several times.
If the authorization fails the code will be executed anyway
  • Loading branch information
waigel committed Jun 20, 2021
1 parent 05e512d commit 7a2dc21
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/src/shared/infra/http/utils/Middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ export class Middleware {
: '';

if (!apiKey) {
this.endRequest(403, 'Invalid secret api key provided', res);
return this.endRequest(403, 'Invalid secret api key provided', res);
}

const account = await this.accountRepo.getAccountBySecretKey(apiKey);
if (!account) {
this.endRequest(403, 'Invalid secret api key provided', res);
return this.endRequest(403, 'Invalid secret api key provided', res);
}

(req as DecodedExpressRequest).decoded = {
Expand Down

0 comments on commit 7a2dc21

Please sign in to comment.