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 */
2727class 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