feat(profile): personal account page with own-profile editing
Add public/profile.html + public/js/profile.js: hash-routed page with
tabs for personal data, password, AI models, prompts and branches
(admin-only), plus clickable counters for the user's own work.
Server:
- users gains email/phone/avatar (init.sql, migration.sql, ensureUserTables)
- GET /api/users/:id — self or admin, returns created_at and branch_ids
- GET /api/users/:id/stats — entries/shorts/feedbacks/lessons/groups counts
- PUT /api/users/:id/profile — name/email/phone/password, audit user.profile.update
- POST /api/users/:id/avatar — upload.single('photo'), audit user.avatar.update
- safeUser() now exposes email/phone/avatar/created_at
- users.avatar added to sweepOrphanedUploads and BROKEN_IMAGE_SOURCES
- getPersonalAiModels()/resolveUserAiProfile() for personal AI profiles;
POST /api/shorts/ai-correct resolves them and 400s on unknown profile
Frontend:
- sidebar entry "Профиль"; .btn-secondary/.btn-xs/.muted in admin.css
- profile.js saves AI and prompt tabs as two independent PUTs
- feedback.js and shorts.js now fill model selects from
GET /api/ai/profiles/options by role (admin sees system profiles,
tutor sees native + own models) so the choice is actually persisted
Docs: AGENTS.md 3h updated, new section 3p.
This commit is contained in:
@@ -206,6 +206,9 @@ CREATE TABLE IF NOT EXISTS users (
|
||||
username VARCHAR(100) NOT NULL UNIQUE,
|
||||
password_hash VARCHAR(255) NOT NULL,
|
||||
name VARCHAR(150),
|
||||
email VARCHAR(255),
|
||||
phone VARCHAR(50),
|
||||
avatar VARCHAR(255),
|
||||
role VARCHAR(20) NOT NULL DEFAULT 'tutor' CHECK (role IN ('admin','tutor')),
|
||||
is_active BOOLEAN DEFAULT true,
|
||||
created_at TIMESTAMPTZ DEFAULT now()
|
||||
|
||||
Reference in New Issue
Block a user