Exemple #1
0
 public static function isLoginSuccessful()
 {
     $data = filter_input_array(INPUT_POST, CustomerController::getLoginRules());
     if (CustomerController::checkValues($data)) {
         $username = $data["uname"];
         $result = UsersDB::getPassword(["uporabnisko_ime" => $username]);
         if ($result != null && password_verify($data["password"], $result["geslo"]) && UsersDB::isCustomer(["uporabnik_id" => $result["id"]]) && UsersDB::isactivate(["id" => $result["id"]])) {
             session_start();
             $_SESSION["active"] = TRUE;
             $_SESSION["role"] = "customer";
             $_SESSION["id"] = $result["id"];
             return true;
         }
     }
     return false;
 }
 public static function check()
 {
     $data = filter_input_array(INPUT_POST, self::getLoginRules());
     if (self::checkValues($data)) {
         $username = $data["uname"];
         $result = UsersDB::getPassword(["uporabnisko_ime" => $username]);
         if ($result != null && password_verify($data["password"], $result["geslo"]) && UsersDB::isCustomer(["uporabnik_id" => $result["id"]]) && UsersDB::isActivate(["id" => $result["id"]])) {
             $_SESSION["active"] = TRUE;
             $_SESSION["role"] = "customer";
             $_SESSION["id"] = $result["id"];
             ViewHelper::redirect(BASE_URL . "customer");
         } else {
             $data["password"] = "";
             self::login($data);
         }
     } else {
         $data["password"] = "";
         self::login($data);
     }
 }