ValidateApiToken
in package
Use case for validating API tokens.
Tokens are hashed before lookup since only hashes are stored in the database.
Tags
Table of Contents
Properties
- $repository : UserRepositoryInterface
- User repository.
- $tokenHasher : TokenHasher
- Token hasher.
Methods
- __construct() : mixed
- Create a new ValidateApiToken use case.
- execute() : User|null
- Execute to validate an API token.
Properties
$repository
User repository.
private
UserRepositoryInterface
$repository
$tokenHasher
Token hasher.
private
TokenHasher
$tokenHasher
Methods
__construct()
Create a new ValidateApiToken use case.
public
__construct(UserRepositoryInterface $repository[, TokenHasher|null $tokenHasher = null ]) : mixed
Parameters
- $repository : UserRepositoryInterface
-
User repository
- $tokenHasher : TokenHasher|null = null
-
Token hasher
execute()
Execute to validate an API token.
public
execute(string $token) : User|null
The provided plaintext token is hashed before lookup since only hashes are stored in the database.
Parameters
- $token : string
-
The API token to validate (plaintext)
Return values
User|null —The user if token is valid, null otherwise