Skip to content

Commit db73664

Browse files
kravcikdg
authored andcommitted
readme: Updated (#39)
Fix doc to get via DIC, prevent: Deprecated Non-static method Nette\Security\Passwords::verify() should not be called statically
1 parent bb3e14d commit db73664

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

readme.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,12 @@ use Nette\Security as NS;
123123
class MyAuthenticator implements NS\IAuthenticator
124124
{
125125
public $database;
126+
public $passwords;
126127

127-
function __construct(Nette\Database\Connection $database)
128+
function __construct(Nette\Database\Connection $database, NS\Passwords $passwords)
128129
{
129130
$this->database = $database;
131+
$this->passwords = $password;
130132
}
131133

132134
function authenticate(array $credentials)
@@ -139,7 +141,7 @@ class MyAuthenticator implements NS\IAuthenticator
139141
throw new NS\AuthenticationException('User not found.');
140142
}
141143

142-
if (!NS\Passwords::verify($password, $row->password)) {
144+
if (!$passwords->verify($password, $row->password)) {
143145
throw new NS\AuthenticationException('Invalid password.');
144146
}
145147

@@ -153,9 +155,8 @@ Class `MyAuthenticator` communicates with the database using Nette\Database laye
153155
This authenticator would be configured in the `config.neon` file like this:
154156

155157
```
156-
common:
157-
services:
158-
authenticator: MyAuthenticator
158+
services:
159+
authenticator: MyAuthenticator
159160
```
160161

161162

0 commit comments

Comments
 (0)