ValidateSession
in package
Use case for validating user sessions.
Checks if the current session is valid and restores user context.
Tags
Table of Contents
Constants
- SESSION_USER_ID = 'LWT_USER_ID'
- Session key for storing the user ID.
Properties
- $repository : UserRepositoryInterface
- User repository.
Methods
- __construct() : mixed
- Create a new ValidateSession use case.
- execute() : User|null
- Execute the session validation.
- destroySession() : void
- Destroy the current session.
- findUser() : User|null
- Find a user by ID.
Constants
SESSION_USER_ID
Session key for storing the user ID.
private
mixed
SESSION_USER_ID
= 'LWT_USER_ID'
Properties
$repository
User repository.
private
UserRepositoryInterface
$repository
Methods
__construct()
Create a new ValidateSession use case.
public
__construct(UserRepositoryInterface $repository) : mixed
Parameters
- $repository : UserRepositoryInterface
-
User repository
execute()
Execute the session validation.
public
execute() : User|null
Return values
User|null —The authenticated user or null if invalid
destroySession()
Destroy the current session.
private
destroySession() : void
findUser()
Find a user by ID.
private
findUser(int $userId) : User|null
Parameters
- $userId : int
-
User ID