Skip to content

Commit c39f8b6

Browse files
committed
removed deprecated IAuthenticator (BC break)
1 parent 3908bb7 commit c39f8b6

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
@@ -55,7 +55,7 @@ class User
5555

5656
/** Session storage for current user */
5757
private UserStorage $storage;
58-
private ?IAuthenticator $authenticator;
58+
private ?Authenticator $authenticator;
5959
private ?Authorizator $authorizator;
6060
private ?IIdentity $identity = null;
6161
private ?bool $authenticated = null;
@@ -64,7 +64,7 @@ class User
6464

6565
public function __construct(
6666
UserStorage $storage,
67-
?IAuthenticator $authenticator = null,
67+
?Authenticator $authenticator = null,
6868
?Authorizator $authorizator = null,
6969
) {
7070
$this->storage = $storage;
@@ -98,9 +98,7 @@ public function login(
9898
$this->identity = $user;
9999
} else {
100100
$authenticator = $this->getAuthenticator();
101-
$this->identity = $authenticator instanceof Authenticator
102-
? $authenticator->authenticate(...func_get_args())
103-
: $authenticator->authenticate(func_get_args());
101+
$this->identity = $authenticator->authenticate(...func_get_args());
104102
}
105103

106104
$id = $this->authenticator instanceof IdentityHandler
@@ -191,7 +189,7 @@ final public function refreshStorage(): void
191189
/**
192190
* Sets authentication handler.
193191
*/
194-
public function setAuthenticator(IAuthenticator $handler): static
192+
public function setAuthenticator(Authenticator $handler): static
195193
{
196194
$this->authenticator = $handler;
197195
return $this;
@@ -201,7 +199,7 @@ public function setAuthenticator(IAuthenticator $handler): static
201199
/**
202200
* Returns authentication handler.
203201
*/
204-
final public function getAuthenticator(): IAuthenticator
202+
final public function getAuthenticator(): Authenticator
205203
{
206204
if (!$this->authenticator) {
207205
throw new Nette\InvalidStateException('Authenticator has not been set.');
@@ -214,7 +212,7 @@ final public function getAuthenticator(): IAuthenticator
214212
/**
215213
* Returns authentication handler.
216214
*/
217-
final public function getAuthenticatorIfExists(): ?IAuthenticator
215+
final public function getAuthenticatorIfExists(): ?Authenticator
218216
{
219217
return $this->authenticator;
220218
}

0 commit comments

Comments
 (0)