v2.0.0: Multi-user authentication with JWT
Some checks failed
Build and Push Docker Image / build-and-push (push) Failing after 16s

Features:
- User registration and login with JWT tokens
- All data is now user-specific (multi-tenancy)
- Profile page with integrations and logout
- Automatic migration of existing data to first user

Backend changes:
- Added users and refresh_tokens tables
- Added user_id to all data tables (projects, entries, nodes, dictionaries, words, progress, configs, telegram_integrations, weekly_goals)
- JWT authentication middleware
- claimOrphanedData() for data migration

Frontend changes:
- AuthContext for state management
- Login/Register forms
- Profile page (replaced Integrations)
- All API calls use authFetch with Bearer token

Migration notes:
- On first deploy, backend automatically adds user_id columns
- First user to login claims all existing data
This commit is contained in:
poignatov
2026-01-01 18:21:18 +03:00
parent 6015b62d29
commit 4a06ceb7f6
23 changed files with 1970 additions and 279 deletions

View File

@@ -1,7 +1,9 @@
import React, { useState, useEffect } from 'react'
import { useAuth } from './auth/AuthContext'
import './Integrations.css'
function TelegramIntegration({ onBack }) {
const { authFetch } = useAuth()
const [botToken, setBotToken] = useState('')
const [chatId, setChatId] = useState('')
const [loading, setLoading] = useState(true)
@@ -16,7 +18,7 @@ function TelegramIntegration({ onBack }) {
const fetchIntegration = async () => {
try {
setLoading(true)
const response = await fetch('/api/integrations/telegram')
const response = await authFetch('/api/integrations/telegram')
if (!response.ok) {
throw new Error('Ошибка при загрузке интеграции')
}
@@ -42,7 +44,7 @@ function TelegramIntegration({ onBack }) {
setError('')
setSuccess('')
const response = await fetch('/api/integrations/telegram', {
const response = await authFetch('/api/integrations/telegram', {
method: 'POST',
headers: {
'Content-Type': 'application/json',