Skip to content

Commit b842c85

Browse files
committed
removed deprecated IAuthenticator (BC break)
1 parent 37657e1 commit b842c85

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,7 +13,7 @@
1313
/**
1414
* Performs authentication.
1515
*/
16-
interface Authenticator extends IAuthenticator
16+
interface Authenticator
1717
{
1818
/** Exception error code */
1919
public const
@@ -22,6 +22,13 @@ interface Authenticator extends IAuthenticator
2222
Failure = 3,
2323
NotApproved = 4;
2424

25+
/** Deprecated */
26+
public const
27+
IDENTITY_NOT_FOUND = self::IdentityNotFound,
28+
INVALID_CREDENTIAL = self::InvalidCredential,
29+
FAILURE = self::Failure,
30+
NOT_APPROVED = self::NotApproved;
31+
2532
/**
2633
* Performs an authentication.
2734
* @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
@@ -56,7 +56,7 @@ class User
5656

5757
/** Session storage for current user */
5858
private UserStorage $storage;
59-
private ?IAuthenticator $authenticator;
59+
private ?Authenticator $authenticator;
6060
private ?Authorizator $authorizator;
6161
private ?IIdentity $identity = null;
6262
private ?bool $authenticated = null;
@@ -65,7 +65,7 @@ class User
6565

6666
public function __construct(
6767
UserStorage $storage,
68-
?IAuthenticator $authenticator = null,
68+
?Authenticator $authenticator = null,
6969
?Authorizator $authorizator = null,
7070
) {
7171
$this->storage = $storage;
@@ -95,9 +95,7 @@ public function login(string|IIdentity $user, ?string $password = null): void
9595
$this->identity = $user;
9696
} else {
9797
$authenticator = $this->getAuthenticator();
98-
$this->identity = $authenticator instanceof Authenticator
99-
? $authenticator->authenticate(...func_get_args())
100-
: $authenticator->authenticate(func_get_args());
98+
$this->identity = $authenticator->authenticate(...func_get_args());
10199
}
102100

103101
$id = $this->authenticator instanceof IdentityHandler
@@ -188,7 +186,7 @@ final public function refreshStorage(): void
188186
/**
189187
* Sets authentication handler.
190188
*/
191-
public function setAuthenticator(IAuthenticator $handler): static
189+
public function setAuthenticator(Authenticator $handler): static
192190
{
193191
$this->authenticator = $handler;
194192
return $this;
@@ -198,7 +196,7 @@ public function setAuthenticator(IAuthenticator $handler): static
198196
/**
199197
* Returns authentication handler.
200198
*/
201-
final public function getAuthenticator(): IAuthenticator
199+
final public function getAuthenticator(): Authenticator
202200
{
203201
if (!$this->authenticator) {
204202
throw new Nette\InvalidStateException('Authenticator has not been set.');
@@ -211,7 +209,7 @@ final public function getAuthenticator(): IAuthenticator
211209
/**
212210
* Returns authentication handler.
213211
*/
214-
final public function getAuthenticatorIfExists(): ?IAuthenticator
212+
final public function getAuthenticatorIfExists(): ?Authenticator
215213
{
216214
return $this->authenticator;
217215
}

0 commit comments

Comments
 (0)