text: const pool = require("../controllers/dbConnection");
  
  const reqAuth = async (req, res, next) => {
    const token = String(req.headers.authorization);
    try {
      const response=await pool.query("SELECT * FROM active_session WHERE token=$1",[token])
      if (response.rows.length == 1) {
        return next();
      } else {
        return res.json({success: false, msg: 'User is not logged on'});
      }
    } catch (error) {
      res.send("Error: " + error);
    }
  };
  
  module.exports = {
    reqAuth: reqAuth,
  };
  