db = new BancaDati(); return $this; } public function exists() { return true; } public function loginWithUsername(string $username, string $password) : string { $userObject = $this->db->select("utente", ["nomeUtente" => $username]); if(!$userObject){ return false; } $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]); 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; } }