<commit_before>module.exports = function (req, res, next) {
  if (Admin.isSignedIn(req)) return next();

  if (req.session.userId === req.param('userId')) return next();

  Membership.inSameCommunity([req.session.userId, req.param('userId')])
    .then(same => {
      if (same) return next();

      Membership.inSameNetwork(req.session.userId, req.param('userId'))
      .then(same => (same ? next() : res.forbidden()));
    })
    .catch(res.serverError);
};<commit_msg>handle bad user urls<commit_after>module.exports = function (req, res, next) {
  if (Admin.isSignedIn(req)) return next()

  if (req.session.userId === req.param('userId')) return next()
  if (isNaN(Number(req.param('userId')))) return res.notFound()

  Membership.inSameCommunity([req.session.userId, req.param('userId')])
  .then(same => {
    if (same) return next()

    Membership.inSameNetwork(req.session.userId, req.param('userId'))
    .then(same => (same ? next() : res.forbidden()))
  })
  .catch(res.serverError)
}
{'fraction_non_alphanumeric': 0.19019019019019018, 'fraction_numerical': 0.0, 'mean_word_length': 4.319148936170213, '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': '4541201', 'n_tokens_mistral': 333, 'n_tokens_neox': 339, 'n_words': 63}