Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit c934bcc

Browse files
committed
Fixes #12 : use false result check at stmt->fetchObject() to handle not found data ( auth failure )
1 parent 311f3d0 commit c934bcc

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/UserRepository/PdoDatabase.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ public function authenticate(string $credential, string $password = null) : ?Use
4949

5050
$stmt = $this->pdo->prepare($sql);
5151
$stmt->bindParam(':username', $credential);
52+
$stmt->execute();
5253

53-
if (! $stmt->execute()) {
54+
$result = $stmt->fetchObject();
55+
if (! $result) {
5456
return null;
5557
}
5658

57-
$result = $stmt->fetchObject();
58-
5959
return password_verify($password, $result->{$this->config['field']['password']})
6060
? $this->generateUser($credential, $this->getRolesFromUser($credential))
6161
: null;

0 commit comments

Comments
 (0)