From cbd4862e6d428890006fb7ed9010911cb45d98dc Mon Sep 17 00:00:00 2001 From: Tom <147888129+Treize-tx@users.noreply.github.com> Date: Tue, 21 Nov 2023 15:17:57 +0100 Subject: [PATCH] =?UTF-8?q?DELETE:=20ScientistGateway.php=20et=20UserGatew?= =?UTF-8?q?ay.php=20supprim=C3=A9s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/model/gateways/ScientistGateway.php | 16 --- project/src/model/gateways/UserGateway.php | 113 ------------------ 2 files changed, 129 deletions(-) delete mode 100755 project/src/model/gateways/ScientistGateway.php delete mode 100755 project/src/model/gateways/UserGateway.php diff --git a/project/src/model/gateways/ScientistGateway.php b/project/src/model/gateways/ScientistGateway.php deleted file mode 100755 index d200eec..0000000 --- a/project/src/model/gateways/ScientistGateway.php +++ /dev/null @@ -1,16 +0,0 @@ -con = $co; - } - -// function findByName(string $name) :? Scientist { -// $usr = null; -// } -} \ No newline at end of file diff --git a/project/src/model/gateways/UserGateway.php b/project/src/model/gateways/UserGateway.php deleted file mode 100755 index 7563880..0000000 --- a/project/src/model/gateways/UserGateway.php +++ /dev/null @@ -1,113 +0,0 @@ -con=$con; - } - - public function login(string $email, string $password): bool - { - $sql = "SELECT * FROM Utilisateur WHERE email=:email"; - $this->con->executeQuery($sql, array( - ':email' => array($email, PDO::PARAM_STR) - )); - - $result = $this->con->getOneResult(); - - if (!empty($result)) { - return password_verify($password,$result['password']); - } - return false; - } - public function addUser(string $email, string $password): void - { - $sql = "INSERT INTO Utilisateur (email, password) VALUES (:email, :password)"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':email', $email); - $stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT)); - $stmt->execute(); - } - public function deleteUser(int $id): void - { - $sql = "DELETE FROM Utilisateur WHERE idJoueur=:id"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':id', $id); - $stmt->execute(); - } - public function updateUser(int $id, string $email, string $password): void - { - $sql = "UPDATE Utilisateur SET email=:email, password=:password WHERE idJoueur=:id"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':id', $id); - $stmt->bindValue(':email', $email); - $stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT)); - $stmt->execute(); - } - public function getUser(int $id): User - { - $sql = "SELECT * FROM Utilisateur WHERE idJoueur=:id"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':id', $id); - $stmt->execute(); - $result = $stmt->fetch(); - return new User($result['id'], $result['email'], $result['password']); - } - public function getUsers(): array - { - $sql = "SELECT * FROM utilisateur"; - $stmt = $this->con->prepare($sql); - $stmt->execute(); - $result = $stmt->fetchAll(); - $users = []; - foreach ($result as $user) { - $users[] = new User($user['id'], $user['email'], $user['password']); - } - return $users; - } - public function getHashedPasswordById(int $id): string - { - $sql = "SELECT password FROM Utilisateur WHERE idJoueur=:id"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':id', $id); - $stmt->execute(); - $result = $stmt->fetch(); - return $result['password']; - } - public function getHashedPassword(int $email): string - { - $sql = "SELECT password FROM Utilisateur WHERE email=:email"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':email', $email); - $stmt->execute(); - $result = $stmt->fetch(); - return $result['password']; - } - public function getUserId(string $email): int - { - $sql = "SELECT idJoueur FROM Utilisateur WHERE email=:email"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':email', $email); - $stmt->execute(); - $result = $stmt->fetch(); - return $result['id']; - } - public function getUserByEmailAndPassword(string $email, string $password): User - { - $sql = "SELECT * FROM utilisateur WHERE email=:email AND password=:password"; - $stmt = $this->con->prepare($sql); - $stmt->bindValue(':email', $email); - $stmt->bindValue(':password', password_hash($password, PASSWORD_DEFAULT)); - $stmt->execute(); - $result = $stmt->fetch(); - return new User($result['id'], $result['email'], $result['password']); - } -}