public function W3CTokenAuth::authenticate in W3C Validator 8
Authenticates the user.
Parameters
\Symfony\Component\HttpFoundation\Request|null $request: The request object.
Return value
\Drupal\Core\Session\AccountInterface|null AccountInterface - in case of a successful authentication. NULL - in case where authentication failed.
Overrides AuthenticationProviderInterface::authenticate
File
- src/
Authentication/ Provider/ W3CTokenAuth.php, line 55
Class
- W3CTokenAuth
- Oauth authentication provider.
Namespace
Drupal\w3c_validator\Authentication\ProviderCode
public function authenticate(Request $request) {
$token = $request->query
->get('HTTP_W3C_VALIDATOR_TOKEN');
// If a token is there.
if (!empty($token) && ($user = $this->w3cTokenManager
->getUserFromToken($token))) {
// Retrieve the current accessed URL.
$current_url = Url::fromRoute('<current>');
// Log the access.
$this->logger
->notice('Request to validate private page @url using token @token for user @user', [
'@url' => $current_url
->toString(),
'@token' => $token,
'@user' => $user
->label(),
]);
return $user;
}
return NULL;
}