make it possible to have username

This commit is contained in:
bence committed 2023-04-09 02:29:46 +02:00
1 parent 366abf61b3
commit 151112bd2a
7 files changed
+44 -6

No files matched your search

+17
View File
@@ -27,6 +27,23 @@ class UserRepository implements IUserRepository
return $this->pdm->selectFromDb($select, User::class);
}
public function getByUsername(string $username): ?User
{
$select = new Select(\Container::$dbConnection);
$select->where('username', '=', $username);
return $this->pdm->selectFromDb($select, User::class);
}
public function getByEmailOrUsername(string $emailOrUsername): ?User
{
if (filter_var($emailOrUsername, FILTER_VALIDATE_EMAIL)) {
return $this->getByEmail($emailOrUsername);
}
return $this->getByUsername($emailOrUsername);
}
public function getByGoogleSub(string $sub): ?User
{
$select = new Select(\Container::$dbConnection);