admin felület különválasztva
This commit is contained in:
224
.roo/history.md
224
.roo/history.md
@@ -202,3 +202,227 @@ A `GET /expenses/` endpoint (`backend/app/api/v1/endpoints/expenses.py:130-139`)
|
||||
|
||||
### 📄 Dokumentáció
|
||||
`docs/cost_pipeline_audit.md` - Teljes pipeline audit a frontendtől a DB-ig.
|
||||
|
||||
## 2026-06-23 - P0 Architecture Audit Fixes: Vendor Leak & Expense Priority
|
||||
|
||||
### 🎯 Cél
|
||||
Az Architect által auditált P0 hibák kijavítása: vendor org szivárgás megszüntetése, expense organization_id prioritás javítása, frontend payload kiegészítése vendor_organization_id-val.
|
||||
|
||||
### 🔧 Módosított fájlok
|
||||
- **`backend/app/services/provider_service.py`** (632-651. sor) - `quick_add_provider`: Eltávolítva az OrganizationMember létrehozás. A létrehozó user NEM lesz tagja a beszállító szervezetének. Owner_id=None marad.
|
||||
- **`backend/app/api/v1/endpoints/expenses.py`** (398-429. sor) - `create_expense`: Átírva az organization_id feloldási prioritás: 1) asset.current_organization_id, 2) asset.owner_org_id, 3) user active org membership fallback.
|
||||
- **`frontend/src/components/cost/CostEntryWizard.vue`** (690-714. sor) - `vendor_organization_id` és `external_vendor_name` root szintű payload mezők hozzáadva.
|
||||
- **`frontend/src/stores/cost.ts`** - `AddExpensePayload` interface kiegészítve `vendor_organization_id` és `external_vendor_name` mezőkkel; `addExpense()` body-ba is átadva.
|
||||
|
||||
### 🗄️ Adatbázis Cleanup
|
||||
- **`backend/scripts/fix_vendor_leak.py`** (ideiglenes, futás után törölve)
|
||||
- A) Törölve `fleet.organization_members` rekord (org_id=63, user_id=28) - phantom ADMIN jog megvonva
|
||||
- B) Javítva `fleet_finance.asset_costs` rekord: organization_id=63 → 21, vendor_organization_id=63 beállítva
|
||||
|
||||
### ✅ Verifikáció
|
||||
- Backend restart: ✅ Sikeres
|
||||
- Python syntax check: ✅ provider_service.py OK, expenses.py OK
|
||||
- Vite build: ✅ Sikeres (255 modules, 6.97s)
|
||||
|
||||
## 2026-06-23 - P0 Tenant Isolation & Vehicle Mapping Audit
|
||||
|
||||
### Scope
|
||||
Full-stack audit of vehicle dropdown tenant isolation failure in CostsView.vue
|
||||
|
||||
### Elemzett fájlok
|
||||
- `backend/app/api/v1/endpoints/assets.py` - GET /assets/vehicles (229-318)
|
||||
- `frontend/src/views/costs/CostsView.vue` - Vehicle dropdown & org switch (330-565)
|
||||
- `frontend/src/stores/vehicle.ts` - fetchVehicles() (141-158)
|
||||
- `frontend/src/stores/auth.ts` - switchOrganization() & active_organization_id (687-717)
|
||||
- `frontend/src/stores/cost.ts` - defense-in-depth org injection (71)
|
||||
|
||||
### Adatbázis: tester_pro (User ID: 28)
|
||||
- 2 organization: Test Company (ID:1, 19 vehicles) + Private_28 (ID:21, 6 vehicles) = 25 total
|
||||
- Schema: identity.users, fleet.organization_members, fleet.organizations, vehicle.assets
|
||||
|
||||
### Root Cause
|
||||
Frontend cache staleness: vehicles load once in onMounted(), never refresh on org switch. The watch on active_organization_id only re-fetches costs, not vehicles.
|
||||
|
||||
### Verdict
|
||||
Backend filtering is correct (JWT scope_id). Database schema is correct. Fix requires adding `vehicleStore.fetchVehicles()` to the org switch watch in CostsView.vue:549.
|
||||
|
||||
### Report
|
||||
`docs/p0_tenant_isolation_vehicle_mapping_audit_report.md`
|
||||
|
||||
## 2026-06-23 - P0 Tenant Isolation Fix: CostsView.vue org switch watcher
|
||||
|
||||
### 🎯 Cél
|
||||
Frontend tenant isolation fix: garázsváltáskor a CostsView.vue watch blokkja most már reseteli a jármű szűrőt (`selectedVehicleFilter.value = null`), újratölti a járműveket az új garázs scope-jával (`vehicleStore.fetchVehicles()`), és frissíti a költségeket.
|
||||
|
||||
### 🔧 Módosított fájlok
|
||||
- `frontend/src/views/costs/CostsView.vue` — watch blokk kiegészítése: jármű szűrő reset + vehicleStore.fetchVehicles() hívás
|
||||
|
||||
### ✅ Verifikáció
|
||||
- Vite build: ✅ Sikeres (0 hiba)
|
||||
- `vehicleStore.fetchVehicles()` mindig küld GET kérést (nincs belső cache guard)
|
||||
|
||||
## 2026-06-23 - P0 EXECUTION: UI Switcher, Subscription Widget & Menu Alignment
|
||||
|
||||
### 🎯 Cél
|
||||
A P0 audit riportban azonosított hibák kijavítása: garázsválasztó szűrés, előfizetés widget jármű limit megjelenítés, mobil menü igazítás, backend admin jogosultság javítás.
|
||||
|
||||
### 🔧 Változtatások
|
||||
|
||||
**1. HeaderCompanySwitcher.vue — Garázsválasztó javítás**
|
||||
- Eltávolítva az `org_type !== 'individual'` szűrő a `companyOrganizations` computed property-ből
|
||||
- Létrehozva új `individualOrganizations` computed property a privát garázsokhoz
|
||||
- Dropdown most két csoportra van osztva: "👤 Saját garázsok" (individual) és "🏢 Céges garázsok" (business)
|
||||
- Privát garázsokra kattintva `switchOrganization()` hívódik, majd `/dashboard` navigáció
|
||||
- Eltávolítva a keménykódolt "Private Garage" gomb — helyette dinamikus lista
|
||||
|
||||
**2. SubscriptionStatusWidget.vue — Jármű limit megjelenítés**
|
||||
- Hozzáadva `useVehicleStore` import és `vehicleCount` computed property
|
||||
- Hozzáadva `maxVehicles` computed property (org vagy user szintről)
|
||||
- Második progress bar a jármű telítettséghez (🚗 Járművek: X / Y)
|
||||
- Színkódolt sáv: zöld (<75%), sárga (75-90%), piros (>90%)
|
||||
- Ha nincs limit (0 vagy null): "Korlátlan" felirat
|
||||
- Dátum formázás és lejárati információ hozzáadva
|
||||
|
||||
**3. PrivateLayout.vue — Mobil menü igazítás**
|
||||
- "Költségek" gombhoz hozzáadva `justify-end` és `text-right` osztályok
|
||||
- A gomb ikonja és szövege jobbra igazítva
|
||||
|
||||
**4. organizations.py — Backend admin jogosultság javítás**
|
||||
- `PUT /{org_id}/subscription` végpontról eltávolítva a `RequireSystemCapability(Capability.CAN_MANAGE_SUBSCRIPTIONS)` függőség
|
||||
- Helyette `_check_org_admin_access(org_id, current_user.id, db)` hívás — így org ADMIN/OWNER is kezelheti a saját előfizetését
|
||||
|
||||
**5. organization.ts — TypeScript típus javítás**
|
||||
- `org_type` mező kötelezővé téve (eltávolítva a `?` optional flag)
|
||||
|
||||
### ✅ Verifikáció
|
||||
- Vite build: ✅ Sikeres (6.75s, 0 hiba)
|
||||
- Backend Python szintaxis: ✅ Sikeres
|
||||
- API konténer újraindítás: ✅ Sikeres
|
||||
|
||||
## 2026-06-23 - P0 HOTFIX: Cost Wizard Edit Mode Bug (POST vs PUT)
|
||||
|
||||
### 🎯 Cél
|
||||
A CostEntryWizard szerkesztés módban POST helyett PUT hívást indítson, hogy ne hozzon létre duplikátumot.
|
||||
|
||||
### 🔧 Módosított fájlok
|
||||
|
||||
1. **`backend/app/schemas/asset_cost.py`** - Új `AssetCostUpdate` Pydantic schema (minden mező opcionális)
|
||||
2. **`backend/app/api/v1/endpoints/expenses.py`** - Új `PUT /expenses/{expense_id}` végpont a meglévő költségrekordok módosítására
|
||||
3. **`frontend/src/stores/cost.ts`** - Új `updateExpense(id, payload)` action a store-ban, ami `PUT /expenses/{id}`-t hív
|
||||
4. **`frontend/src/components/cost/CostEntryWizard.vue`** - `handleSubmit()` logika javítva: ha `props.editCost.id` létezik, `updateExpense()`-t hív, egyébként `addExpense()`-t
|
||||
|
||||
### 🗑️ Adatbázis cleanup
|
||||
- Duplikált rekord törölve: `55214098-74be-4261-a101-7fd9159e10d8` (asset_id=`deb42aea-1f48-4a70-85b5-ba451d005577`, amount_gross=5500.00)
|
||||
|
||||
### ✅ Verifikáció
|
||||
- Vite build: ✅ Sikeres (7.09s, 255 module, 0 hiba)
|
||||
- Backend Python AST parse: ✅ Sikeres (expenses.py, asset_cost.py)
|
||||
- `AssetCostUpdate` schema import: ✅ Sikeres (14 field)
|
||||
- Duplikátum törlés: ✅ Sikeres
|
||||
|
||||
## 2026-06-23 - P0 Final Polish: Wizard UX & Menu Alignment
|
||||
|
||||
### 🎯 Cél
|
||||
Három kritikus UI hiba javítása: dátum hydratáció Edit módban, Fizetési Mód logika és UI átrendezés, mobil menü jobbra igazítás.
|
||||
|
||||
### 🔧 Módosított fájlok
|
||||
|
||||
1. **`frontend/src/components/cost/CostEntryWizard.vue`**
|
||||
- **Date Hydration Fix (watch block):** `form.invoiceDate` és `form.paymentDeadline` most már mindig érvényes `YYYY-MM-DD` stringet kap (vagy `''` ha null). Két forrást is ellenőriz: `data.invoice_date` (JSONB) és `editData.invoice_date` (top-level). Használ `rawDate.split('T')[0] || rawDate.slice(0, 10) || ''` fallback láncot.
|
||||
- **Payment Method UI áthelyezés:** A `<select>` a STEP 3 blokkban a Számla kelte és Fizetési határidő ELÉ került (Invoice Number után, Invoice Date előtt).
|
||||
- **Payment Deadline dinamikus rejtés:** `v-if="form.paymentMethod === 'TRANSFER'"` a Payment Deadline inputon — CASH/CARD esetén eltűnik.
|
||||
- **Mentési automatizmus:** `handleSubmit()`-ben, ha `form.paymentMethod === 'CASH' || 'CARD'`, a `form.paymentDeadline` automatikusan `form.invoiceDate || form.date` értékre áll.
|
||||
|
||||
2. **`frontend/src/layouts/PrivateLayout.vue`**
|
||||
- **Mobile Menu "Költségek" jobbra igazítás:** `flex-row-reverse` osztály hozzáadva, hogy az ikon a jobb szélre tapadjon. Megtartva `justify-end` és `text-right`.
|
||||
|
||||
3. **`frontend/src/layouts/OrganizationLayout.vue`**
|
||||
- **"Költségek" gomb hozzáadva** a hamburger menübe (hiányzott). Jobbra igazított `flex-row-reverse` stílussal, a `navigateToCosts()` függvény az `/organization/:id/costs` oldalra navigál.
|
||||
|
||||
### ✅ Verifikáció
|
||||
- Vite build: ✅ Sikeres (7.31s, 255 modules, 0 hiba)
|
||||
|
||||
## 2026-06-24 — P0 3D Capability Matrix Audit (Issue #283)
|
||||
|
||||
**Architect:** Completed read-only audit of all SQLAlchemy models for 3D RBAC readiness.
|
||||
|
||||
**Findings:**
|
||||
- **D1 (Global Roles):** `UserRole` enum with 6 values (SUPERADMIN, ADMIN, MODERATOR, SALES_REP, SERVICE_MGR, USER) — ✅ sufficient
|
||||
- **D2 (Tenant Roles):** `OrgUserRole` enum (OWNER, ADMIN, ACCOUNTANT, DRIVER, VIEWER) + `OrgRole.permissions` JSONB + `OrganizationMember.permissions` JSON — ✅ sufficient
|
||||
- **D3 (Subscription Capabilities):** ⚠️ Partial — `SubscriptionTier.rules` JSONB exists but no standardized feature capability format. **Missing:** `custom_features` JSONB on Organization model
|
||||
- **D4 (Cost Category Gating):** ⚠️ Partial — `CostCategory.min_tier` exists but no `required_feature` column
|
||||
|
||||
**Report:** `docs/p0_3d_capability_matrix_audit_report.md`
|
||||
**Proposed migrations:** 3 ALTER TABLE statements (SubscriptionTier.feature_capabilities, Organization.custom_features, CostCategory.required_feature) + optional FeatureCapability enum
|
||||
|
||||
## 2026-06-24 — P0 3D Capability Matrix Implementation (Code)
|
||||
|
||||
### 🎯 Cél
|
||||
A 3D Capability Matrix teljes implementációja: modellek bővítése, adatbázis migráció, Capability Resolver Service, és a /categories API végpont capability-alapú védelme.
|
||||
|
||||
### 🔧 Módosított fájlok
|
||||
- `backend/app/models/core_logic.py` — SubscriptionTier.feature_capabilities (JSONB)
|
||||
- `backend/app/models/marketplace/organization.py` — Organization.custom_features (JSONB) + subscription_tier reláció
|
||||
- `backend/app/models/fleet_finance/models.py` — CostCategory.required_feature (String(50))
|
||||
- `backend/app/services/capability_service.py` — Új Capability Resolver Service (Superadmin Fast-Pass)
|
||||
- `backend/app/api/v1/endpoints/dictionaries.py` — /cost-categories endpoint capability filtering
|
||||
|
||||
### ✅ Verifikáció
|
||||
- Sync Engine: 1213 OK, 0 Fixed, 0 Extra — teljes szinkron
|
||||
- Python import/attribute check: minden modelloszlop és reláció jelen van
|
||||
- resolve_org_capabilities() callable, Fast-Pass működik
|
||||
|
||||
## 2026-06-24 — P0 EXECUTION: Backoffice SSO & Staff Guards
|
||||
|
||||
### 🎯 Cél
|
||||
Cross-subdomain SSO cookie fix, backend staff role dependencies, frontend admin routing guard expansion, and dead link cleanup in AdminLayout.
|
||||
|
||||
### 🔧 Módosított fájlok
|
||||
|
||||
**Phase 1 — Cross-Subdomain Cookies (Backend)**
|
||||
- `backend/app/core/config.py` — Added `COOKIE_DOMAIN: str = ".servicefinder.hu"` setting
|
||||
- `backend/app/api/v1/endpoints/auth.py` — Added `domain=settings.COOKIE_DOMAIN` to both `set_cookie()` calls (login:127, verify-email:221)
|
||||
|
||||
**Phase 2 — Scalable Backend Dependencies**
|
||||
- `backend/app/api/deps.py` — Added `STAFF_ROLES` set (SUPERADMIN, ADMIN, MODERATOR, SALES_REP, SERVICE_MGR)
|
||||
- `backend/app/api/deps.py` — Added `get_current_staff` dependency (admits all staff roles)
|
||||
- `backend/app/api/deps.py` — Added `RequireRole(allowed_roles: List[UserRole])` flexible dependency factory
|
||||
|
||||
**Phase 3 — Frontend Guards & Store**
|
||||
- `frontend/src/stores/auth.ts` — Expanded `isAdmin` getter to include SALES_REP and SERVICE_MGR
|
||||
- `frontend/src/router/index.ts` — Expanded `requiresAdmin` guard to admit all 5 staff roles
|
||||
|
||||
**Phase 4 — Admin UI Cleanup**
|
||||
- `frontend/src/layouts/AdminLayout.vue` — Removed dead sidebar links: /admin/vehicles, /admin/translations, /admin/system, /admin/audit
|
||||
|
||||
### ✅ Verifikáció
|
||||
- Vite build: ✅ Sikeres (255 modules, 7.13s, 0 hiba)
|
||||
- Python AST parse: ✅ config.py, auth.py, deps.py — all syntax OK
|
||||
- Python import test: ✅ `settings.COOKIE_DOMAIN` = `.servicefinder.hu`
|
||||
- Python import test: ✅ `STAFF_ROLES` contains all 5 roles, `get_current_staff` and `RequireRole` are callable
|
||||
|
||||
## 2026-06-24 - P0 READ & PLAN: Admin Container Separation Audit
|
||||
|
||||
### 🎯 Cél
|
||||
Architecture audit for strictly isolated Admin container. Read docker-compose.yml, NPM proxy configs, and directory structure.
|
||||
|
||||
### 🔧 Eredmények
|
||||
|
||||
**1. DOCKER ARCHITECTURE:** ✅ 3 admin-related containers exist
|
||||
- `sf_admin_ui` (Streamlit, port 8501) — Active HITL panel
|
||||
- `sf_admin_frontend` (Nuxt 3, port 8502) — Placeholder only
|
||||
- `sf_public_frontend` (Vite/Vue, port 8503) — Contains embedded admin views
|
||||
|
||||
**2. CRITICAL FINDING:** Admin views are split across two codebases
|
||||
- Full admin views (Dashboard, Users, Packages, Services, Login) exist in `frontend/src/views/admin/`
|
||||
- Separate Nuxt 3 container at `frontend/admin/` is provisioned but empty (placeholder app.vue only)
|
||||
- NPM routing already correct: `admin.servicefinder.hu` → `sf_admin_frontend:8502`
|
||||
|
||||
**3. GITEA CARDS CREATED:**
|
||||
- #284 — Main audit card (FINISHED)
|
||||
- #285 — Build Nuxt 3 Admin App
|
||||
- #286 — Remove Admin Views from Public Frontend
|
||||
- #287 — Production Dockerfile for Admin
|
||||
- #288 — Deprecate Streamlit Admin
|
||||
|
||||
**4. REPORT:** `plans/admin_container_separation_audit.md`
|
||||
|
||||
Reference in New Issue
Block a user