hue-portal-backend / README.md
davidtran999's picture
Upload README.md with huggingface_hub
ae5e195 verified
|
raw
history blame
1.52 kB
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>" } (header Authorization: Bearer <access>)
  • GET /api/auth/me/ – lấy thông tin user hiện tại
  • POST /api/auth/register/ – chỉ admin gọi được; truyền thêm role (admin hoặc user) 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 role admin hoặc cung cấp header X-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”.