{"size": 317, "ext": "js", "max_stars_repo_path": "server/Middlewares/auth.js", "max_stars_repo_name": "akarX23/Blogger", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server/Middlewares/auth.js", "max_issues_repo_name": "akarX23/Blogger", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server/Middlewares/auth.js", "max_forks_repo_name": "akarX23/Blogger", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 19.8125, "max_line_length": 74, "alphanum_fraction": 0.5678233438}
const User = require("../Models/user");

let auth = (req, res, next) => {
  let token = req.body.token;

  User.findByToken(token, (err, user) => {
    if (err || !user) return res.status(200).json({ isAuth: false, err });

    req.token = token;
    req.user = user;
    next();
  });
};

module.exports = { auth };
