@davoodmehraban89 / Factor-easy / commits / a5391f9
Fork 0

سامانه صدور فاکتور و حسابداری

docs(phase0): register observed admin signup trigger-order failure before implementing fix

davoodmehraban89 committed Oct 12, 2026 at 11:14 UTC a5391f9091f7485f62518b0427ba9971f4023287
1 file changed +9
PROJECT_STATE.md
+9
@@ -324,3 +324,12 @@ Owner reports login blocked with generic 'check internet/VPN' network error on l
324 - PR #92 merged by squash to protected `main` exact SHA **`745bdc847a3c2db22048d1d545da0fad0ae5cc67`**. On that SAME SHA: Quality **`38218505600` SUCCESS**, static job `114708817767` Chromium **85/85 PASS (51.1s)** + Golden/draft-posted safety and three disposable DB jobs; Security **`38218505535` SUCCESS**, Release gate **`38218679192` SUCCESS**, gated Pages **`38218725537` SUCCESS**. Concurrent duplicate Release `38218648536` CANCELLED and Pages `38218713325` SKIPPED, neither counted as success.
325 - Independent read-only remote proof: authorized Windows desktop `DESKTOP-71SJ63M` GET to `https://factoreasy.ir/?phase0dark=20261012` includes `20261012-phase0-dark-contrast-v1` (**True**); fetched live `js/ux-hardening-r2.js?v=20261012-phase0-dark-contrast-v1` contains dark shell and secondary-button selectors (**True / True**). This proves deployed asset parity, **not** customer-authenticated visual experience.
326 - **Acceptance:** F0-06 targeted contrast **RELEASED / CONTROLLED-QA-PASSED**; broader modal/RTL keyboard/import/export/dark-light owner UI and physical-device acceptance remains **UNVERIFIED**. F0-01/02/03/04/07 and F0-08 outstanding gates remain; **PHASE 0 OPEN / NOT OWNER ACCEPTED**. No customer data, ledger, Auth, RLS, roles, schema, Supabase migration, financial posting or paid-service changes. Rollback: revert PR #92, run gated Pages deploy, refresh cached bundle.
327 +
328 +
329 +## 2026-10-12 F0-01/F0-07 admin provisioning 400 — OWNER REPORTED / ROOT CAUSE VERIFIED / FIX STARTED
330 +- **Owner request:** Screenshot of real Central Admin > New User form reporting `Edge Function returned a non-2xx status code` despite fields entered; fix the issue *before* resuming Phase 0 work. Do **not** record name, email, password, tokens, IP or request metadata from owner screenshot in project logs. Do not create a live user or change an existing password during diagnosis.
331 +- **Verified live source evidence:** protected `main` `487471fe9154ff7b94fab56335ffeb000494c72a`; live Supabase project `hcsixhqbyuhpshfwqpjx`, Edge `admin-user-management` ACTIVE v3 with `verify_jwt=true`. Request log on 2026-10-12 07:13:44Z: authenticated POST to Edge returned HTTP 400; corresponding Auth Admin `/auth/v1/admin/users` returned HTTP 500, with Auth error `ERROR: organization license not found (SQLSTATE 23503)` / `unexpected_failure`. These are exact live logs, **not** guessed password, email, network or unauthorized-role failure.
332 +- **Root cause:** live `public.handle_new_user()` inserts `public.organization_members` active owner BEFORE `public.licenses`; `private.enforce_organization_member_seat()` BEFORE INSERT requires license row and raises SQLSTATE 23503 if absent. Existing migrations lack the function's post-phone-identity live definition in main. Transaction fails during Auth user creation and rolls back. Actual constraints reviewed: licenses FK to profile/organization only, no membership FK; license-first ordering is valid and satisfies unmodified seat trigger.
333 +- **Bounded intended correction:** add reviewed, idempotent one-function migration to reorder fresh-user bootstrap as `profiles → organizations → licenses → owner membership`, preserving all current live email/phone signup support, default `role='user'`, trial entitlements, security-definer fixed search_path and seat enforcement. Reproduce 23503 in disposable PostgreSQL fixture, then verify successful bootstrap and existing seat-limit rejection. Add safe UI parsing of Edge structured error codes and regression test so admin form no longer displays opaque non-2xx errors. Run static/Chromium, disposable DB, Security; gate on exact SHA. Production migration only after independent tests and confirmed source/version equivalence; no changes to existing user/license rows, RLS, Auth JWT verification, or financial data. Rollback: approved previous function definition (do not mutate accounts/data). No live account creation without separately approved isolated identity.
334 +- **Dependent continuation:** PR #92 dark-mode work already merged into latest main; verify its exact protected-main gates before further F0-06 work. Phase 0 remains OPEN; do not claim owner E2E pass from synthetic tests or read-only diagnostics.
335 +- **Current status:** ROOT_CAUSE_VERIFIED / REPRODUCE_AND_FIX_IN_PROGRESS.