From 2280fb1d174099f2c6df5663c239572e9b8d2c0f Mon Sep 17 00:00:00 2001 From: emad-salah Date: Tue, 17 Dec 2019 14:18:46 +0100 Subject: [PATCH] Minor auth token fix --- .eslintrc.json | 4 +++- services/auth/auth.js | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index d1038cb0..8bd8ef46 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -60,7 +60,9 @@ "consistent-return": "off", - "no-shadow": "off" + "no-shadow": "off", + // We're usually throwing objects throughout the API to allow for more detailed error messages + "no-throw-literal": "off" }, "parser": "babel-eslint", "env": { diff --git a/services/auth/auth.js b/services/auth/auth.js index a9f786e5..ede8219d 100644 --- a/services/auth/auth.js +++ b/services/auth/auth.js @@ -108,6 +108,9 @@ class Auth { const key = jwt.decode(token).data.timestamp const secrets = await this.readSecrets() const secret = secrets[key] + if (!secret) { + throw { valid: false } + } return new Promise((resolve, reject) => { jwt.verify(token, secret, (err, decoded) => { if (err) {