message: Refactor overlong routes into smaller compose functions
diff: @@ -26,21 +26,7 @@ module.exports = function resetPassword () {
  if (insecurity.hmac(answer) === data.answer) {
  models.User.findByPk(data.UserId).then(user => {
  user.update({ password: newPassword }).then(user => {
  - if (utils.notSolved(challenges.resetPasswordJimChallenge) && user.id === users.jim.id && answer === 'Samuel') {
  - utils.solve(challenges.resetPasswordJimChallenge)
  - }
  - if (utils.notSolved(challenges.resetPasswordBenderChallenge) && user.id === users.bender.id && answer === 'Stop\'n\'Drop') {
  - utils.solve(challenges.resetPasswordBenderChallenge)
  - }
  - if (utils.notSolved(challenges.resetPasswordBjoernChallenge) && user.id === users.bjoern.id && answer === 'West-2082') {
  - utils.solve(challenges.resetPasswordBjoernChallenge)
  - }
  - if (utils.notSolved(challenges.resetPasswordMortyChallenge) && user.id === users.morty.id && answer === '5N0wb41L') {
  - utils.solve(challenges.resetPasswordMortyChallenge)
  - }
  - if (utils.notSolved(challenges.resetPasswordBjoernOwaspChallenge) && user.id === users.bjoernOwasp.id && answer === 'Zaya') {
  - utils.solve(challenges.resetPasswordBjoernOwaspChallenge)
  - }
  + verifySecurityAnswerChallenges(user, answer)
  res.json({ user })
  }).catch(error => {
  next(error)
  @@ -57,3 +43,21 @@ module.exports = function resetPassword () {
  }
  }
  }
  +
  +function verifySecurityAnswerChallenges (user, answer) {
  + if (utils.notSolved(challenges.resetPasswordJimChallenge) && user.id === users.jim.id && answer === 'Samuel') {
  + utils.solve(challenges.resetPasswordJimChallenge)
  + }
  + if (utils.notSolved(challenges.resetPasswordBenderChallenge) && user.id === users.bender.id && answer === 'Stop\'n\'Drop') {
  + utils.solve(challenges.resetPasswordBenderChallenge)
  + }
  + if (utils.notSolved(challenges.resetPasswordBjoernChallenge) && user.id === users.bjoern.id && answer === 'West-2082') {
  + utils.solve(challenges.resetPasswordBjoernChallenge)
  + }
  + if (utils.notSolved(challenges.resetPasswordMortyChallenge) && user.id === users.morty.id && answer === '5N0wb41L') {
  + utils.solve(challenges.resetPasswordMortyChallenge)
  + }
  + if (utils.notSolved(challenges.resetPasswordBjoernOwaspChallenge) && user.id === users.bjoernOwasp.id && answer === 'Zaya') {
  + utils.solve(challenges.resetPasswordBjoernOwaspChallenge)
  + }
  +}
  