Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Emmanuel-Mtz-777/TechStore-Explorer/llms.txt

Use this file to discover all available pages before exploring further.

TechStore Explorer ships two distinct authentication layers: a Livewire-powered web experience for browser users and Laravel Sanctum for machine-to-machine REST API access. Both layers share the same users table and role system, but they use different guards and credential flows.

Web Authentication

The web UI is built on Laravel Breeze (Livewire stack). Breeze provides a complete set of pre-built authentication views and Livewire form components out of the box.

Register

New accounts are created via the Breeze registration form. Every new user is automatically assigned the customer role.

Login

The LoginForm Livewire form object handles credential validation, rate-limiting (max 5 attempts), and session creation. After a successful login, users are redirected to the main product listing.

Email Verification

Routes requiring the verified middleware redirect unverified users to the email verification notice page until they confirm their address.

Password Reset & Confirmation

Breeze includes password reset (via emailed link) and password confirmation flows. Profile management is available at GET /profile.
All Breeze auth routes (register, login, logout, password reset, email verification) are defined in routes/auth.php, which is required at the bottom of routes/web.php.

Login rate limiting

The LoginForm class enforces a maximum of 5 failed attempts before locking out the IP/email pair. Lock-out duration is determined by Laravel’s RateLimiter, and the throttle key combines the lowercased email with the client IP address.
protected function throttleKey(): string
{
    return Str::transliterate(Str::lower($this->email).'|'.request()->ip());
}

Role-Based Access Control

TechStore Explorer uses a simple two-role model seeded into the roles table.

Seeded roles

// database/seeders/RoleSeeder.php
Role::create(['name' => 'admin']);
Role::create(['name' => 'customer']);
RoleAssigned toAccess
adminManually promoted usersDashboard + all /api/roles/* endpoints
customerAll new registrations (web & API)Standard authenticated routes

Middleware

Two custom middleware classes enforce role-based access: AdminMiddleware — used for web routes. Checks that the authenticated user’s role name is admin; aborts with 403 otherwise (or 401 if not authenticated at all).
public function handle(Request $request, Closure $next): Response
{
    if (!auth()->check()) {
        abort(401);
    }

    if (auth()->user()->role?->name !== 'admin') {
        abort(403);
    }

    return $next($request);
}
AdminApiMiddleware — used for API routes. Returns a JSON 403 response for non-admin users so API consumers receive a machine-readable error instead of an HTML error page.

Protected routes

RouteMiddleware stackDescription
GET /dashboardauth, verified, adminAdmin analytics dashboard
GET /api/roles/*auth:sanctum, admin.apiRole management API endpoints

User Model

The User model uses three key traits that enable both authentication layers:
use HasFactory, Notifiable, HasApiTokens;
TraitPurpose
HasApiTokensEnables Sanctum personal access token creation and validation
NotifiableAllows sending email notifications (password reset, etc.)
HasFactoryProvides model factory support for tests and seeders
Fillable fields: name, email, password, role_id Hidden fields: password, remember_token Relationships:
  • role()belongsTo(Role::class) — the user’s assigned role
  • wishlists()hasMany(Wishlist::class) — all wishlist entries for this user

Test Accounts

The following seeded accounts are available in a freshly migrated development environment:
EmailPasswordRole
admin@example.comadmin123admin
test@example.comcustomer123customer
For REST API authentication using Bearer tokens, see the API Authentication page. It covers how to obtain a Sanctum personal access token, attach it to requests, and revoke tokens on logout.

Build docs developers (and LLMs) love