metadata
title: Hue Portal Backend
emoji: ⚖️
colorFrom: green
colorTo: blue
sdk: docker
sdk_version: 0.0.1
app_file: app.py
pinned: false
license: apache-2.0
Authentication & Authorization
Seed tài khoản mặc định
Sau khi thiết lập môi trường:
cd backend/hue_portal
source ../venv/bin/activate
python manage.py migrate
python manage.py seed_default_users
Các biến môi trường hỗ trợ tuỳ biến (tùy chọn):
| Biến | Mặc định |
|---|---|
DEFAULT_ADMIN_USERNAME |
admin |
DEFAULT_ADMIN_EMAIL |
admin@example.com |
DEFAULT_ADMIN_PASSWORD |
Admin@123 |
DEFAULT_USER_USERNAME |
user |
DEFAULT_USER_EMAIL |
user@example.com |
DEFAULT_USER_PASSWORD |
User@123 |
API đăng nhập
POST /api/auth/login/– body{ "username": "...", "password": "..." }POST /api/auth/logout/– body{ "refresh": "<refresh_token>" }(headerAuthorization: Bearer <access>)GET /api/auth/me/– lấy thông tin user hiện tạiPOST /api/auth/register/– chỉ admin gọi được; truyền thêmrole(adminhoặcuser) khi tạo tài khoản mới.
Phân quyền
- Upload tài liệu (
/api/legal-documents/upload/) yêu cầu user roleadminhoặc cung cấp headerX-Upload-Token. - Frontend hiển thị nút “Đăng nhập” ở trang chủ và trên thanh điều hướng. Khi đăng nhập thành công sẽ hiển thị tên + role, kèm nút “Đăng xuất”.