Users, Roles, Teams and API Tokens

Who can sign in, what they may do, how visitors register, and how the helpdesk works.

In the user guide: the Users & Access chapter and Support Tickets.

The user model

App\Models\User is an Authenticatable that implements MustVerifyEmail, HasMedia (avatar), uses Sanctum tokens (HasApiTokens), Spatie roles (HasRoles), the hand-rolled teams trait (HasTeams), notifications, soft deletes, the searchable trait and page-visit tracking. Relations: social() (OAuth links), pages(), posts() (via author_id), tickets(), profile(). activate() and inactivate() dispatch UserWasActivated / UserWasInactivated. Email verification is required only when setting('activation_required') is on.

Booking and TruCommerce keep their own Customer entities that are separate from User; staff and providers in Booking are users with extra roles.

Roles and permissions

Create permissions for your plugin as shown in Permissions and roles.

Registration and sign-in

  1. RegisterAuth\RegisteredUserController creates the user and fires Laravel's Registered event. UserRegistered creates a default team for the user (role admin in that team) and assigns public_user_role.
  2. VerifyEmail verification routes (verification.notice, verification.verify, throttled). Admin and front each have their own copies in routes/admin_auth.php and routes/auth.php.
  3. Social loginAuth\SocialAuthController (Google and Facebook through Socialite) auto-provisions a user and stores a Social row (provider + social_id) on first sign-in. Credentials are configured in Settings → General (FACEBOOK_* / GOOGLE_*).
  4. Two-factorGoogle2FA (TOTP). The 2fa alias protects admin routes; TwoFactorMiddleware protects front/user routes. Both delegate to App\Services\Authenticator, so treat both as active.

reCAPTCHA protects forms when configured (CaptchaTrait), and login is rate limited by the standard Laravel limiter.

The visitor account area

Registered visitors get a self-service area at /user/* (routes/app.php, UserController): dashboard (the user.dashboard dashboard, fed by modules), profile, password change, two-factor, Sanctum API tokens, notifications, browser sessions, account deletion (soft delete + goodbye email, re-activation link), teams and support tickets. These routes sit behind TwoFactorMiddleware, auth and verified.

Teams

A hand-rolled Jetstream-style collaboration workspace, not content tenancy: Team, TeamRole, TeamInvitation, the HasTeams trait, TeamController and TeamInvitationController. Invitations use signed URLs and a TeamInvitation Mailable. Team roles (admin, user) and API-token abilities are declared through the Roles facade in DotartisanServiceProvider::registerWorkspaceRoles(). Keep "team role" and "CMS role" separate in your head: they are unrelated systems.

Support tickets

AspectDetail
ModelsTicket, TicketMessage, TicketCategory, TicketActivity, TicketReference; they use the legacy HasConfigModel trait (string primary-key toggle)
StatesOPEN → ANSWERED → CLOSED (plain strings)
Two UIs, one policyAdmin helpdesk (Admin\TicketController, gated by view all tickets) and visitor UI (TicketController); both authorise through TicketPolicy
FlowTicketObserver writes a TicketActivity row and fires TicketOpenEvent → TicketCreatedNotification (mail + database). A reply fires TicketMessageEvent and flips the state to ANSWERED. Closing fires TicketCloseEvent, which currently has no listener
Configconfig/tickets.php: attachments (5 files, 5 MB, pdf,png,jpg,txt), at most 3 open tickets per user, categories on, priorities low/medium/high, autoclose-days = 7
Auto-closeCommand dotartisan:tickets:autoclose exists but is not scheduled by default; add it to a scheduler if you want it

API access

routes/api.php exposes one Sanctum-protected endpoint, GET /api/v1/whoami (api.whoami). Users create personal access tokens in their account area (user.token). The API middleware group applies EnsureFrontendRequestsAreStateful, throttling and the demo guard. For a plugin API follow the existing convention: prefix v1, auth:sanctum middleware, Eloquent API resources.

Notifications and mail

Notifications use the mail and database channels only: TicketCreatedNotification, TicketUpdatedNotification, SendGoodbyeEmail, TruCommerce's ProductLowStockNotification. The only Mailable class is TeamInvitation; Booking sends transactional mail through its own notification templates. Do not assume a Mailable exists for a given email — check first.