db = new BancaDati(); return $this; } public function exists() { return true; } public function loginWithUsername(string $username, string $password) : string { $query = $this->db->select("utente", ["nomeUtente" => $username]); if(!$query){ return false; } $userObject = $query[0]; $this->id = $userObject["id"]; $this->username = $userObject["nomeUtente"]; $this->email = $userObject["email"]; $this->password = $userObject["parolaDordine"]; $this->token = $this->db->createUUID(); if($this->password != $password){ return false; // ungültiges password } $this->db->update("utente", $this->id, ["gettone" => $this->token]); return $this->token; } public function loginWithToken(string $token){ $userObject = $this->db->select("utente", ["gettone" => $token])[0]; if(!$userObject){ return false; } $this->id = $userObject["id"]; $this->username = $userObject["nomeUtente"]; $this->email = $userObject["email"]; $this->password = $userObject["parolaDordine"]; $this->token = $token; return $this; } }