Spaces:
Running
Running
Commit History
8 days ago
-
security(owner-directives): universal admin-approval enforcement + login-only chatbot + stale-shell cache cure
ahmdelbaz28-uxRoot causes fixed: 1) APPROVAL BYPASS (pre-gate accounts): the v17 column DEFAULT grandfathered every pre-gate account as 'approved' and the gate ran ONLY at login — a pre-gate user (or his surviving 30-day session) entered and used the platform with zero admin confirmation. Fixed at THREE layers: - approvalGateVerdict: fail-closed for everything not literally 'approved' - context.loadUserFromDb: per-request gate re-check (kills live sessions of non-approved accounts on their very next request) - db-init v18 one-time idempotent backfill: pre-gate rows -> pending + tokenVersion bump (queue-approved/rejected/admins untouched) - decideApproval(approve) stamps emailVerifiedAt: the admin approval IS the email confirmation — never asked twice (owner promise) 2) CHATBOT OPEN TO GUESTS: the REST surface was intentionally anonymous (UI already redirected guests). POST /, POST /stream and feedback votes now require a session — guests get the stable 401 A…b34ee20
20 days ago
-
fix(auth): remember-this-device session persistence — kill false-401 logout chain
ahmdelbaz28-uxUser report: closing and reopening the app always demanded a fresh login even though 'Remember this device' was checked. Three chained root causes: 1. FALSE-401 ON DB HICCUP (api/context.ts): a transient MySQL failure inside the auth pipeline was swallowed by createContext's blanket catch, the request degraded to GUEST, requireAuth threw UNAUTHORIZED, and the client destroyed the stored session. One brief DB outage (HF Space wake-up, free-tier connection reset, cold-start race) = permanent logout. CURE: loadUserFromDbWithRetry — one quick DB retry, then the failure surfaces as a retryable INTERNAL_SERVER_ERROR (5xx) instead of a guest 401. createContext rethrows TRPCError instead of swallowing it. 2. GRACE WINDOW BROKE THE 30-DAY PROMISE (api/context.ts): expired-but- signature-valid tokens were renewed only within 24h of expiry, while the remember cookie lasts 30 days — any idle gap beyond ~8 days forced a re-login. CURE: EXPIRED_TOKEN_GRACE_S = AUTH_CO…c50c1a3