Final Class Yiisoft\User\Method\WebAuth
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Yiisoft\ |
Implementation of the AuthenticatorWithChallengeInterface for authenticating users in the web applications.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| authenticate() | Yiisoft\ |
|
| challenge() | Yiisoft\ |
|
| withAuthUrl() | Returns a new instance with the specified authentication URL. | Yiisoft\ |
Method Details
| public mixed __construct ( Yiisoft\ | ||
| $currentUser | Yiisoft\ |
|
| $responseFactory | \ |
|
public function __construct(
private readonly CurrentUser $currentUser,
private readonly ResponseFactoryInterface $responseFactory,
) {}
| public ?\ | ||
| $request | \ |
|
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 ( \ | ||
| $response | \ |
|
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 self withAuthUrl ( string $url ) | ||
| $url | string |
The authentication URL. |
public function withAuthUrl(string $url): self
{
$new = clone $this;
$new->authUrl = $url;
return $new;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.