<commit_before>const config = require('config');
const jwt = require('jsonwebtoken');

function required() {
  return (req, res, next) => {
    const token = req.body.token || req.query.token || req.headers['x-access-token'];
    if (!token) {
      res.status(403).send({
        message: config.auth.invalid_token,
      });
      return;
    }

    jwt.verify(token, config.session.config.secret, (err) => {
      if (err) {
        res.status(403).send({
          message: config.auth.invalid_token,
        });
        return;
      }
      next();
    });
  };
}

module.exports = { required };<commit_msg>fix bug<commit_after>const config = require('config');
const jwt = require('jsonwebtoken');

function required() {
  return (req, res, next) => {
    const token = req.body.token || req.query.token || req.headers['x-access-token'];
    if (!token) {
      res.status(403).send({
        message: config.api.auth.invalid_token,
      });
      return;
    }

    jwt.verify(token, config.session.config.secret, (err) => {
      if (err) {
        res.status(403).send({
          message: config.api.auth.invalid_token,
        });
        return;
      }
      next();
    });
  };
}

module.exports = { required };
{'fraction_non_alphanumeric': 0.17263843648208468, 'fraction_numerical': 0.009771986970684038, 'mean_word_length': 2.3579234972677594, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3336294', 'n_tokens_mistral': 402, 'n_tokens_neox': 391, 'n_words': 71}