From c5bec46b52794c9133ef716e37504242942bc7cf Mon Sep 17 00:00:00 2001 From: Clayton Wilson Date: Tue, 1 Oct 2019 16:08:53 -0400 Subject: [PATCH] Fix fbAuth function not extracting 'Bearer ' --- functions/util/fbAuth.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/util/fbAuth.js b/functions/util/fbAuth.js index 04d71ed..a9243cc 100644 --- a/functions/util/fbAuth.js +++ b/functions/util/fbAuth.js @@ -7,8 +7,8 @@ module.exports = (req, res, next) => { let idToken; // Checking that the token exists in the header of the request - if (req.headers.authorization) { - idToken = req.headers.authorization; + if (req.headers.authorization && req.headers.authorization.startsWith('Bearer ')) { + idToken = req.headers.authorization.split('Bearer ')[1]; } else { console.error('No token found'); return res.status(403).json({ error: 'Unauthorized'});