{"size": 505, "ext": "js", "max_stars_repo_path": "middleware/hasPermission.js", "max_stars_repo_name": "paulsmithkc/pet-adoption-v2", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "middleware/hasPermission.js", "max_issues_repo_name": "paulsmithkc/pet-adoption-v2", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "middleware/hasPermission.js", "max_forks_repo_name": "paulsmithkc/pet-adoption-v2", "max_forks_repo_forks_event_min_datetime": "2021-10-05T19:37:14.000Z", "max_forks_repo_forks_event_max_datetime": "2021-11-16T18:53:00.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 33.6666666667, "max_line_length": 90, "alphanum_fraction": 0.6138613861}
function hasPermission(permission) {
  return (req, res, next) => {
    if (!req.auth) {
      return res.status(401).json({ error: 'You are not logged in!' });
    } else if (!req.auth.permissions) {
      return res.status(403).json({ error: 'You do not have any permissions!' });
    } else if (!req.auth.permissions[permission]) {
      return res.status(403).json({ error: `You do not have permission ${permission}!` });
    } else {
      return next();
    }
  };
}

module.exports = hasPermission;