feat: add user authentication system

- User model (users table) with bcrypt password hashing
- JWT-based login API (POST /api/auth/login, GET /api/auth/me)
- Default admin account (admin/admin123) auto-created on startup
- Login page with centered dark-themed login card
- Route guards + Axios interceptors for token management
- Login page renders without sidebar (standalone layout)
- Gunicorn --preload to avoid worker DDL race condition
This commit is contained in:
2026-06-14 23:22:53 +08:00
parent 521cf0269c
commit cd41e59afc
14 changed files with 430 additions and 11 deletions
+1
View File
@@ -1,6 +1,7 @@
"""Pydantic schema registry."""
from app.schemas.agent import AgentBatchRegister, AgentBatchRegisterResult, AgentCreate, AgentHeartbeat, AgentOut, AgentUpdate # noqa: F401
from app.schemas.auth import LoginRequest, TokenResponse, UserInfo, UserOut # noqa: F401
from app.schemas.execution import ExecutionOut, ExecutionReport # noqa: F401
from app.schemas.notification import ( # noqa: F401
AlertAcknowledge,
+37
View File
@@ -0,0 +1,37 @@
"""Pydantic schemas — Auth."""
from datetime import datetime
from pydantic import BaseModel, Field
class LoginRequest(BaseModel):
username: str = Field(..., max_length=64)
password: str = Field(..., max_length=128)
class UserInfo(BaseModel):
id: int
username: str
display_name: str
email: str
model_config = {"from_attributes": True}
class TokenResponse(BaseModel):
access_token: str
token_type: str = "bearer"
user: UserInfo
class UserOut(BaseModel):
id: int
username: str
display_name: str
email: str
is_active: bool
created_at: datetime
updated_at: datetime
model_config = {"from_attributes": True}