- Implement session management API (/api/v1/session/create, verify, logout) - Add session restoration from localStorage on page reload - Fix session_id priority when loading drafts (use current, not old from DB) - Add unified_id and claim_id to wizard payload sent to n8n - Add Docker volume for frontend HMR (Hot Module Replacement) - Add comprehensive session logging for debugging Components updated: - backend/app/api/session.py (NEW) - Session management endpoints - backend/app/main.py - Include session router - frontend/src/components/form/Step1Phone.tsx v2.0 - Create session after SMS - frontend/src/pages/ClaimForm.tsx v3.8 - Session restoration & priority fix - frontend/src/components/form/StepWizardPlan.tsx v1.4 - Add unified_id/claim_id - docker-compose.yml - Add frontend volume for live reload Session flow: 1. User verifies phone -> session created in Redis (24h TTL) 2. session_token saved to localStorage 3. Page reload -> session restored automatically 4. Draft selected -> current session_id used (not old from DB) 5. Wizard submit -> unified_id, claim_id, session_id sent to n8n 6. Logout -> session removed from Redis & localStorage Fixes: - Session token not persisting after page reload - unified_id missing in n8n webhook payload - Old session_id from draft overwriting current session - Frontend changes requiring container rebuild
42 lines
1.5 KiB
JavaScript
42 lines
1.5 KiB
JavaScript
// Парсим результат CreateWebContact
|
||
const rawResult = $node["CreateWebContact"].json.result;
|
||
|
||
const contactData = JSON.parse(rawResult); // {"contact_id": "396625", "is_new": false}
|
||
|
||
const phone = $('Edit Fields').first().json.phone;
|
||
|
||
// Получаем session_id
|
||
const session_id = $('Edit Fields').first().json.session_id;
|
||
|
||
// Получаем unified_id из ноды user_get
|
||
const unified_id = $('user_get').first().json.unified_id || null;
|
||
|
||
// Формируем session для Redis (БЕЗ claim_id, с unified_id)
|
||
const sessionData = {
|
||
// claim_id убран - используем только session_id на этих этапах
|
||
unified_id: unified_id, // ← unified_id из PostgreSQL (получаем от user_get)
|
||
contact_id: contactData.contact_id, // ← распарсенный ID из CreateWebContact
|
||
phone: phone,
|
||
is_new_contact: contactData.is_new, // ← флаг нового контакта
|
||
status: "draft",
|
||
current_step: 1,
|
||
created_at: new Date().toISOString(),
|
||
updated_at: new Date().toISOString(),
|
||
documents: {},
|
||
email: null,
|
||
bank_name: null
|
||
};
|
||
|
||
return {
|
||
session: session_id,
|
||
session_id: session_id, // Добавляем для совместимости
|
||
unified_id: unified_id, // ✅ Добавляем unified_id в return
|
||
contact_id: contactData.contact_id,
|
||
is_new_contact: contactData.is_new,
|
||
phone: phone,
|
||
redis_key: `session:${session_id}`, // ✅ Используем session_id для ключа Redis
|
||
redis_value: JSON.stringify(sessionData),
|
||
ttl: 604800
|
||
};
|
||
|