private function auth($id, $password)
 {
     $instanceRepo = new InstanceRepository();
     $instance = $instanceRepo->get($id);
     if ($instance->password == $password) {
         return true;
     }
     return false;
 }
 private function generateId()
 {
     $id = RandomGenerator::alphanumeric(25);
     $instanceRepo = new InstanceRepository();
     while ($instanceRepo->get($id)->id != null) {
         $id = RandomGenerator::alphanumeric(25);
     }
     return $id;
 }
Example #3
0
 public function index($instanceId)
 {
     $user = AuthController::auth();
     $scoreRepo = new ScoreRepository();
     $scores = $scoreRepo->getScoreByInstanceId($instanceId);
     $instanceRepo = new InstanceRepository();
     $instance = $instanceRepo->get($instanceId);
     usort($scores, function ($a, $b) {
         if ($a->score == $b->score) {
             return 0;
         }
         return $a->score < $b->score ? 1 : -1;
     });
     $this->view('score.php', ['user' => $user, 'scores' => $scores, 'instance' => $instance]);
 }