75386c354a
Schema: - shop_customers (company_id, name, phone unique-per-tenant, email, password, client_id auto-linked, last_login_at) - online_orders.shop_customer_id nullable FK Auth: - New 'shop' guard (session driver, shop_customers provider) in config/auth.php - ShopCustomer Authenticatable with hashed password cast and BelongsToTenant global scope — login attempts naturally scoped to current tenant subdomain Flow: - ShopAuthController: register / login / logout / account - Register auto-links to existing Client by phone match - /shop/account: order history (only the logged customer's orders) + profile - Checkout prefills name/phone/email from logged customer + sets shop_customer_id (and client_id from auto-link) on the placed order - Layout nav switches between Login/Register and "👤 Name + Ieșire" Tests (8 new): - register creates customer + auto-login - register auto-links existing Client by phone - duplicate phone rejected - login validates credentials - /account requires auth (redirects to /shop/login) - /account lists only the logged customer's orders - checkout attaches shop_customer_id - customers tenant-isolated Full suite: 117 passed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
66 lines
1.6 KiB
PHP
66 lines
1.6 KiB
PHP
<?php
|
|
|
|
use App\Models\Central\SuperAdmin;
|
|
use App\Models\Tenant\User;
|
|
|
|
return [
|
|
|
|
'defaults' => [
|
|
'guard' => env('AUTH_GUARD', 'web'),
|
|
'passwords' => env('AUTH_PASSWORD_BROKER', 'users'),
|
|
],
|
|
|
|
'guards' => [
|
|
// Tenant-side auth (per-company users on <slug>.service.mir.md).
|
|
'web' => [
|
|
'driver' => 'session',
|
|
'provider' => 'users',
|
|
],
|
|
|
|
// Central-side auth (super-admins on service.mir.md/admin).
|
|
'central' => [
|
|
'driver' => 'session',
|
|
'provider' => 'super_admins',
|
|
],
|
|
|
|
// Public storefront customer auth (per-tenant).
|
|
'shop' => [
|
|
'driver' => 'session',
|
|
'provider' => 'shop_customers',
|
|
],
|
|
],
|
|
|
|
'providers' => [
|
|
'users' => [
|
|
'driver' => 'eloquent',
|
|
'model' => env('AUTH_MODEL', User::class),
|
|
],
|
|
'super_admins' => [
|
|
'driver' => 'eloquent',
|
|
'model' => SuperAdmin::class,
|
|
],
|
|
'shop_customers' => [
|
|
'driver' => 'eloquent',
|
|
'model' => \App\Models\Tenant\ShopCustomer::class,
|
|
],
|
|
],
|
|
|
|
'passwords' => [
|
|
'users' => [
|
|
'provider' => 'users',
|
|
'table' => env('AUTH_PASSWORD_RESET_TOKEN_TABLE', 'password_reset_tokens'),
|
|
'expire' => 60,
|
|
'throttle' => 60,
|
|
],
|
|
'super_admins' => [
|
|
'provider' => 'super_admins',
|
|
'table' => 'password_reset_tokens',
|
|
'expire' => 60,
|
|
'throttle' => 60,
|
|
],
|
|
],
|
|
|
|
'password_timeout' => env('AUTH_PASSWORD_TIMEOUT', 10800),
|
|
|
|
];
|