def verifyUser()

in backend/app/utils/auth/PasswordHashing.scala [60:84]


  def verifyUser(maybeUser: Attempt[DBUser], password: String, registrationCheck: RegistrationCheck)(implicit ec: ExecutionContext): Attempt[DBUser] =
    maybeUser.flatMap { user =>
      user.password match {
        case Some(userPassword) =>
          verify(userPassword, password).flatMap {
            case true =>
              (registrationCheck, user.registered) match {
                case (RequireRegistered, false) =>
                  Attempt.Left[DBUser](LoginFailure("User requires registration"))
                case (RequireNotRegistered, true) =>
                  Attempt.Left[DBUser](LoginFailure("User already registered"))
                case _ =>
                  Attempt.Right(user)
              }
            case false =>
              Attempt.Left[DBUser](LoginFailure("Incorrect password"))
          }
        // the user has no password set so any provided password is wrong
        case None => Attempt.Left[DBUser](LoginFailure("Incorrect password"))
      }
    }.recoverWith {
      case err: UserDoesNotExistFailure =>
        // Hash the password anyway so the client does not perceive a difference in how long the login takes
        hash(password).flatMap(_ => Attempt.Left[DBUser](err))
    }