| 28 | | final class UserRepository extends AbstractRepository implements UserRepositoryInterface |
| 29 | | { |
| 30 | | public function getUserEntityByUserCredentials( |
| 31 | | string $username, |
| 32 | | #[\SensitiveParameter] |
| 33 | | string $password, |
| 34 | | string $grantType, |
| 35 | | ClientEntityInterface $clientEntity, |
| 36 | | ): ?UserEntityInterface { |
| 37 | | try { |
| 38 | | $authDatabase = new AuthDatabase($this->configuration); |
| 39 | | if (!$authDatabase->checkCredentials($username, $password)) { |
| 40 | | return null; |
| 41 | | } |
| 42 | | } catch (\Throwable) { |
| 43 | | return null; |
| 44 | | } |
| 45 | | |
| 46 | | $query = sprintf( |
| 47 | | "SELECT user_id FROM %s WHERE login = '%s'", |
| 48 | | $this->table('faquser'), |
| 49 | | $this->db()->escape($username), |
| 50 | | ); |
| 51 | | |
| 52 | | $result = $this->db()->query($query); |
| 53 | | if ($result === false) { |
| 54 | | return null; |
| 55 | | } |
| 56 | | |
| 57 | | $row = $this->db()->fetchObject($result); |
| 58 | | if (!is_object($row) || !property_exists($row, 'user_id') || $row->user_id === null) { |
| 59 | | return null; |
| 60 | | } |
| 61 | | |
| 62 | | $userIdentifier = (string) $row->user_id; |
| 63 | | if ($userIdentifier === '') { |
| 64 | | return null; |
| 65 | | } |
| 66 | | |
| 67 | | $user = new UserEntity(); |
| 68 | | $user->setIdentifier($userIdentifier); |
| 69 | | |
| 70 | | return $user; |
| 71 | | } |
| 72 | | } |