Fix fbAuth function not extracting 'Bearer '

This commit is contained in:
Clayton Wilson 2019-10-01 16:08:53 -04:00
parent cc98fa7884
commit c5bec46b52

View File

@ -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'});