Final Class Yiisoft\User\UserAuth
| Inheritance | Yiisoft\User\UserAuth |
|---|---|
| Implements | Yiisoft\Auth\AuthenticationMethodInterface |
| Deprecated since version | Use {@see \Yiisoft\User\Method\WebAuth}. This class will be removed in the next major version. |
Implementation of the authentication interface for the user.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\User\UserAuth | |
| authenticate() | Yiisoft\User\UserAuth | |
| challenge() | Yiisoft\User\UserAuth | |
| withAuthUrl() | Returns a new instance with the specified authentication URL. | Yiisoft\User\UserAuth |
Method Details
| public __construct( Yiisoft\User\CurrentUser $currentUser, \Psr\Http\Message\ResponseFactoryInterface $responseFactory ): mixed | ||
| $currentUser | Yiisoft\User\CurrentUser | |
| $responseFactory | \Psr\Http\Message\ResponseFactoryInterface | |
public function __construct(private CurrentUser $currentUser, private ResponseFactoryInterface $responseFactory)
{
}
| public authenticate( \Psr\Http\Message\ServerRequestInterface $request ): \Yiisoft\Auth\IdentityInterface|null | ||
| $request | \Psr\Http\Message\ServerRequestInterface | |
public function authenticate(ServerRequestInterface $request): ?IdentityInterface
{
if ($this->currentUser->isGuest()) {
return null;
}
return $this->currentUser->getIdentity();
}
Creates a new instance of the response and adds a Location header with a temporary redirect.
| public challenge( \Psr\Http\Message\ResponseInterface $response ): | ||
| $response | \Psr\Http\Message\ResponseInterface | |
public function challenge(ResponseInterface $response): ResponseInterface
{
return $this->responseFactory
->createResponse(Status::FOUND)
->withHeader('Location', $this->authUrl);
}
Returns a new instance with the specified authentication URL.
| public withAuthUrl( string $url ): self | ||
| $url | string |
The authentication URL. |
public function withAuthUrl(string $url): self
{
$new = clone $this;
$new->authUrl = $url;
return $new;
}
Signup or Login in order to comment.