Skip to main content

Auth

Responsible for authentication and authorization: Sanctum token issuance, passwordless OTP sign-in, role/permission checks behind the admin API, and device sessions.

Tables​

TableDescription
users_usersUser accounts
users_otp_codesOne-time passcodes for passwordless sign-in

Device sessions​

Tokens are Sanctum personal access tokens named after the device the customer signed in from (device_name on sign-in, falling back to the user agent). Signing in replaces only that device's previous token, so sessions from other devices survive. Tokens expire after AUTH_TOKEN_TTL_DAYS (default 7) — or AUTH_TOKEN_SHORT_TTL_DAYS (default 1) when the client sends remember: false — and expired tokens are pruned daily with a 48-hour grace window.

EndpointAudiencePurpose
POST /auth/user/account/sign-outUserRevoke the current token (real sign-out)
GET /auth/user/account/sessionsUserList own sessions (device, last_used_at, is_current)
DELETE /auth/user/account/sessions/{id}UserRevoke one own session
DELETE /auth/user/account/sessionsUserSign out everywhere (revoke all tokens)

The same endpoints serve the storefront and the admin panel (both are Sanctum clients). Admin routes additionally gate on permissions derived from route names and seeded via auth:sync-permissions.

Admin stats​

GET /auth/admin/stats returns customer counts for the dashboard: total customers, new this month, and the month-over-month change.

Events emitted​

EventWhen
UserSignedUpEventA user signs up
UserSignedInEventA user signs in
UserEmailVerifiedEventA user's email is verified
UserActivatedEventA user is activated
UserDeactivatedEventA user is deactivated

Dependencies​

None.