Skip to content

Commit 97de226

Browse files
committed
removed deprecated IAuthenticator (BC break)
1 parent c3dc865 commit 97de226

File tree

4 files changed

+16
-48
lines changed

4 files changed

+16
-48
lines changed

src/Bridges/SecurityDI/SecurityExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function loadConfiguration()
9797
}
9898

9999
$builder->addDefinition($this->prefix('authenticator'))
100-
->setType(Nette\Security\IAuthenticator::class)
100+
->setType(Nette\Security\Authenticator::class)
101101
->setFactory(Nette\Security\SimpleAuthenticator::class, [$usersList, $usersRoles, $usersData]);
102102

103103
if ($this->name === 'security') {

src/Security/Authenticator.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@
1313
/**
1414
* Performs authentication.
1515
*/
16-
interface Authenticator extends IAuthenticator
16+
interface Authenticator
1717
{
18+
/** Exception error code */
19+
public const
20+
IDENTITY_NOT_FOUND = 1,
21+
INVALID_CREDENTIAL = 2,
22+
FAILURE = 3,
23+
NOT_APPROVED = 4;
24+
1825
/**
1926
* Performs an authentication.
2027
* @throws AuthenticationException

src/Security/IAuthenticator.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Security/User.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* @property-read string|int $id
2222
* @property-read array $roles
2323
* @property-read int $logoutReason
24-
* @property IAuthenticator $authenticator
24+
* @property Authenticator $authenticator
2525
* @property Authorizator $authorizator
2626
*/
2727
class User
@@ -52,7 +52,7 @@ class User
5252

5353
/** Session storage for current user */
5454
private UserStorage $storage;
55-
private ?IAuthenticator $authenticator;
55+
private ?Authenticator $authenticator;
5656
private ?Authorizator $authorizator;
5757
private ?IIdentity $identity = null;
5858
private ?bool $authenticated = null;
@@ -61,7 +61,7 @@ class User
6161

6262
public function __construct(
6363
UserStorage $storage,
64-
?IAuthenticator $authenticator = null,
64+
?Authenticator $authenticator = null,
6565
?Authorizator $authorizator = null,
6666
) {
6767
$this->storage = $storage;
@@ -91,9 +91,7 @@ public function login(string|IIdentity $user, ?string $password = null): void
9191
$this->identity = $user;
9292
} else {
9393
$authenticator = $this->getAuthenticator();
94-
$this->identity = $authenticator instanceof Authenticator
95-
? $authenticator->authenticate(...func_get_args())
96-
: $authenticator->authenticate(func_get_args());
94+
$this->identity = $authenticator->authenticate(...func_get_args());
9795
}
9896

9997
$id = $this->authenticator instanceof IdentityHandler
@@ -184,7 +182,7 @@ final public function refreshStorage(): void
184182
/**
185183
* Sets authentication handler.
186184
*/
187-
public function setAuthenticator(IAuthenticator $handler): static
185+
public function setAuthenticator(Authenticator $handler): static
188186
{
189187
$this->authenticator = $handler;
190188
return $this;
@@ -194,7 +192,7 @@ public function setAuthenticator(IAuthenticator $handler): static
194192
/**
195193
* Returns authentication handler.
196194
*/
197-
final public function getAuthenticator(): IAuthenticator
195+
final public function getAuthenticator(): Authenticator
198196
{
199197
if (!$this->authenticator) {
200198
throw new Nette\InvalidStateException('Authenticator has not been set.');
@@ -207,7 +205,7 @@ final public function getAuthenticator(): IAuthenticator
207205
/**
208206
* Returns authentication handler.
209207
*/
210-
final public function getAuthenticatorIfExists(): ?IAuthenticator
208+
final public function getAuthenticatorIfExists(): ?Authenticator
211209
{
212210
return $this->authenticator;
213211
}

0 commit comments

Comments
 (0)