feat: shop customer accounts (register/login + order history)
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>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
@extends('shop.layout')
|
||||
@section('title', 'Login')
|
||||
@section('content')
|
||||
|
||||
<div style="max-width:380px;margin:0 auto;">
|
||||
<h1 style="font-size:22px;margin-bottom:16px;">Intră în cont</h1>
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="card" style="border-color:#fca5a5;background:#fef2f2;margin-bottom:14px;">
|
||||
<ul style="margin:0;padding-left:18px;color:#991b1b;font-size:14px;">
|
||||
@foreach ($errors->all() as $e)<li>{{ $e }}</li>@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="/shop/login" class="card">
|
||||
@csrf
|
||||
<div class="field"><label>Telefon *</label>
|
||||
<input type="text" name="phone" value="{{ old('phone') }}" required placeholder="+373…">
|
||||
</div>
|
||||
<div class="field"><label>Parolă *</label>
|
||||
<input type="password" name="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn block">Intră</button>
|
||||
</form>
|
||||
|
||||
<p class="muted" style="text-align:center;margin-top:12px;">
|
||||
Nu ai cont? <a href="/shop/register" style="color:inherit;text-decoration:underline;">Înregistrare</a>
|
||||
</p>
|
||||
</div>
|
||||
@endsection
|
||||
@@ -0,0 +1,40 @@
|
||||
@extends('shop.layout')
|
||||
@section('title', 'Înregistrare')
|
||||
@section('content')
|
||||
|
||||
<div style="max-width:420px;margin:0 auto;">
|
||||
<h1 style="font-size:22px;margin-bottom:16px;">Înregistrare cont</h1>
|
||||
|
||||
@if ($errors->any())
|
||||
<div class="card" style="border-color:#fca5a5;background:#fef2f2;margin-bottom:14px;">
|
||||
<ul style="margin:0;padding-left:18px;color:#991b1b;font-size:14px;">
|
||||
@foreach ($errors->all() as $e)<li>{{ $e }}</li>@endforeach
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="/shop/register" class="card">
|
||||
@csrf
|
||||
<div class="field"><label>Nume *</label>
|
||||
<input type="text" name="name" value="{{ old('name') }}" required>
|
||||
</div>
|
||||
<div class="field"><label>Telefon *</label>
|
||||
<input type="text" name="phone" value="{{ old('phone') }}" required placeholder="+373…">
|
||||
</div>
|
||||
<div class="field"><label>Email</label>
|
||||
<input type="email" name="email" value="{{ old('email') }}">
|
||||
</div>
|
||||
<div class="field"><label>Parolă *</label>
|
||||
<input type="password" name="password" required minlength="6">
|
||||
</div>
|
||||
<div class="field"><label>Confirmă parola *</label>
|
||||
<input type="password" name="password_confirmation" required minlength="6">
|
||||
</div>
|
||||
<button type="submit" class="btn block">Creează cont</button>
|
||||
</form>
|
||||
|
||||
<p class="muted" style="text-align:center;margin-top:12px;">
|
||||
Ai deja cont? <a href="/shop/login" style="color:inherit;text-decoration:underline;">Login</a>
|
||||
</p>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user