Standard Laravel events
These events are dispatched on both the JWT bearer and HTTP Basic paths:| Event | Fired when |
|---|---|
Illuminate\Auth\Events\Attempting | Bearer, refresh, or credential attempt starts |
Illuminate\Auth\Events\Validated | Successful login path about to bind context |
Illuminate\Auth\Events\Authenticated | Identity bound to the guard |
Illuminate\Auth\Events\Login | Full lifecycle complete |
Illuminate\Auth\Events\Failed | Any bearer, refresh, or credential rejection |
Custom events
| Event | Fired when |
|---|---|
SineMacula\Laravel\Authentication\Events\PrincipalAssigned | Principal resolved and bound to the guard |
SineMacula\Laravel\Authentication\Events\DeviceAuthenticated | Device hydrated and bound to the guard |
SineMacula\Laravel\Authentication\Events\Refreshed | Refresh exchange completed successfully |
SineMacula\Laravel\Authentication\Events\RefreshFailed | Refresh exchange failed |
PrincipalAssigned
Dispatched immediately after the principal resolver binds a principal to a guard. Carries the guard name and the resolved principal instance.
DeviceAuthenticated
Dispatched when a device is hydrated from the devices table and bound to the guard during a bearer or refresh request. Carries the guard name and the device instance. Listeners on this event may persist request metadata — such as last IP address or user-agent — during the authentication lifecycle.
Refreshed
Dispatched after a successful refresh-token exchange. Implements ShouldDispatchAfterCommit, so it fires only after the rotation database transaction commits. Carries the full contextual surface so activity-log consumers can attribute the refresh without a second round-trip through the guard.
RefreshFailed
Dispatched whenever a refresh-token exchange fails. Carries a RefreshFailureReason backed enum so SIEM consumers can count and alert on failure modes without scraping log messages.
RefreshFailureReason reason codes
RefreshFailed carries a RefreshFailureReason backed enum. Every failure path dispatches a distinct reason code so you can attribute events without ambiguity:
| Reason | Value | Meaning |
|---|---|---|
TOKEN_INVALID | token_invalid | Decode, expiry, typ, iss, or aud failure — the refresh token itself is malformed or expired |
DEVICE_UNKNOWN | device_unknown | The device ID in the token did not resolve to a record in the devices table |
ROTATION_MISMATCH | rotation_mismatch | The rotation digest did not match the stored refresh key — stale or tampered token |
ROTATION_REUSE | rotation_reuse | Replay or concurrent rotation detected; the device has been revoked to prevent further use |
DEVICE_REVOKED | device_revoked | The device row was explicitly marked as revoked before the refresh attempt |
AUTHENTICATABLE_MISSING | authenticatable_missing | The device’s authenticatable polymorphic relation could not be loaded |
IDENTITY_INACTIVE | identity_inactive | The resolved identity implements CanBeActive and returned false |
PRINCIPAL_UNRESOLVED | principal_unresolved | The principal resolver returned null for the identity |
PRINCIPAL_MISMATCH | principal_mismatch | The resolved principal does not match the pid hint carried in the refresh token |
PRINCIPAL_INACTIVE | principal_inactive | The resolved principal implements CanBeActive and returned false |
Listening to events
Register listeners in yourEventServiceProvider or using Laravel’s #[AsEventListener] attribute: