From a25992c8f019f2e009323b95ffc18872385d11d6 Mon Sep 17 00:00:00 2001 From: AdamSBlack Date: Thu, 20 May 2021 22:07:07 +0100 Subject: [PATCH] fix for JWT not being added to auth controller --- controllers/authentication.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/controllers/authentication.js b/controllers/authentication.js index e1e162f..e554b60 100644 --- a/controllers/authentication.js +++ b/controllers/authentication.js @@ -1,12 +1,19 @@ +const jwt = require('jsonwebtoken'); + - -async function validateJWT(JWT, Key) { - +async function validateJWT(JWT, key) { + try { + return jwt.verify(jwt.replace("JWT ", ""), key, {algorithms: ['RS256']}); + } catch (exception) { + // TODO add logger to authentication controller + //logger.error(exception); + } + return null; } module.exports = { validateJWT: validateJWT -} \ No newline at end of file +}