Final Class Yiisoft\User\Method\WebAuth
| Inheritance | Yiisoft\User\Method\WebAuth |
|---|---|
| Implements | Yiisoft\Auth\AuthenticationMethodInterface |
Implementation of the AuthenticationMethodInterface for authenticating users in the web applications.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\User\Method\WebAuth | |
| authenticate() | Yiisoft\User\Method\WebAuth | |
| challenge() | Yiisoft\User\Method\WebAuth | |
| withAuthUrl() | Returns a new instance with the specified authentication URL. | Yiisoft\User\Method\WebAuth |
Method Details
| public mixed __construct ( Yiisoft\User\CurrentUser $currentUser, \Psr\Http\Message\ResponseFactoryInterface $responseFactory ) | ||
| $currentUser | Yiisoft\User\CurrentUser | |
| $responseFactory | \Psr\Http\Message\ResponseFactoryInterface | |
public function __construct(
private readonly CurrentUser $currentUser,
private readonly ResponseFactoryInterface $responseFactory
) {
}
| public \Yiisoft\Auth\IdentityInterface|null authenticate ( \Psr\Http\Message\ServerRequestInterface $request ) | ||
| $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 self withAuthUrl ( string $url ) | ||
| $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.