text: const { admin } = require('./admin');
  
  module.exports = (req, res, next) => {
    let idToken;
    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' });
    }
  
    admin
      .auth()
      .verifyIdToken(idToken)
      .then(() => {
        return next()
      })
      .catch((err) => {
        console.error('Error while verifying token ', err);
        return res.status(403).json(err);
      });
  
  
  };
  