From 8539a5c9329ff22d5b85a3d3d121a68efc3f459c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?MSI-7950X=5C=E5=88=98=E6=B3=BD=E6=98=8E?= Date: Mon, 11 May 2026 18:06:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=AF=E5=8A=A8=E7=89=88?= =?UTF-8?q?=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/modules/auth/router.py | 8 +++----- backend/requirements.txt | 2 +- docker-compose.yml | 8 +++----- frontend/Dockerfile | 2 +- frontend/src/views/flow/FlowEditor.vue | 2 +- init-db/01-init.sql | 2 +- 6 files changed, 10 insertions(+), 14 deletions(-) diff --git a/backend/modules/auth/router.py b/backend/modules/auth/router.py index 0d2eb22..d17a6aa 100644 --- a/backend/modules/auth/router.py +++ b/backend/modules/auth/router.py @@ -4,7 +4,7 @@ import jwt from fastapi import APIRouter, Depends, HTTPException, Request from sqlalchemy import select from sqlalchemy.ext.asyncio import AsyncSession -from passlib.context import CryptContext +import bcrypt from database import get_db from models import User, UserRole, Role, RolePermission, Permission @@ -12,8 +12,6 @@ from schemas import LoginRequest, TokenResponse, UserOut, RoleOut from config import settings router = APIRouter(prefix="/api/auth", tags=["auth"]) -pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto") - async def get_permission_codes(db: AsyncSession, role_ids: list[uuid.UUID]) -> list[str]: result = await db.execute( @@ -53,7 +51,7 @@ async def get_user_roles(db: AsyncSession, user_id: uuid.UUID) -> list[RoleOut]: async def login(req: LoginRequest, db: AsyncSession = Depends(get_db)): result = await db.execute(select(User).where(User.username == req.username)) user = result.scalar_one_or_none() - if not user or not pwd_context.verify(req.password, user.password_hash): + if not user or not bcrypt.checkpw(req.password.encode('utf-8'), user.password_hash.encode('utf-8')): raise HTTPException(401, "用户名或密码错误") if user.status != "active": raise HTTPException(403, "账户已被禁用") @@ -97,4 +95,4 @@ async def get_me(request: Request, db: AsyncSession = Depends(get_db)): def hash_password(password: str) -> str: - return pwd_context.hash(password) \ No newline at end of file + return bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt()).decode('utf-8') \ No newline at end of file diff --git a/backend/requirements.txt b/backend/requirements.txt index 517ba60..4648827 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -5,7 +5,7 @@ asyncpg>=0.30.0 redis>=5.2.0 httpx>=0.28.0 python-jose[cryptography]>=3.3.0 -passlib[bcrypt]>=1.7.4 +bcrypt>=4.0.0 pydantic>=2.0.0 pydantic-settings>=2.0.0 alembic>=1.14.0 diff --git a/docker-compose.yml b/docker-compose.yml index 8964260..0b1a5b7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: "3.8" - services: postgres: image: postgres:16-alpine @@ -13,7 +11,7 @@ services: - postgres_data:/var/lib/postgresql/data - ./init-db:/docker-entrypoint-initdb.d ports: - - "5432:5432" + - "5431:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U enterprise"] interval: 5s @@ -28,7 +26,7 @@ services: volumes: - redis_data:/data ports: - - "6379:6379" + - "6378:6379" backend: build: @@ -49,7 +47,7 @@ services: LLM_API_BASE: ${LLM_API_BASE:-https://api.openai.com/v1} LLM_MODEL: ${LLM_MODEL:-gpt-4o-mini} ports: - - "8000:8000" + - "8100:8000" volumes: - ./backend:/app diff --git a/frontend/Dockerfile b/frontend/Dockerfile index b44f565..67f7046 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -2,7 +2,7 @@ FROM node:20-alpine AS build WORKDIR /app COPY package*.json ./ -RUN npm ci +RUN npm install COPY . . RUN npm run build diff --git a/frontend/src/views/flow/FlowEditor.vue b/frontend/src/views/flow/FlowEditor.vue index fb6fcb2..331925b 100644 --- a/frontend/src/views/flow/FlowEditor.vue +++ b/frontend/src/views/flow/FlowEditor.vue @@ -181,7 +181,7 @@ const visibleEdges = computed(() => { x1: source.x + 80, y1: source.y + 100, x2: target.x + 80, y2: target.y + 5, } - }).filter(Boolean) + }).filter((edge): edge is { x1: number; y1: number; x2: number; y2: number } => edge !== null) }) function onDragStart(e: DragEvent, node: (typeof nodeTypes)[0]) { diff --git a/init-db/01-init.sql b/init-db/01-init.sql index aeef8dc..8bff70a 100644 --- a/init-db/01-init.sql +++ b/init-db/01-init.sql @@ -196,7 +196,7 @@ INSERT INTO role_permissions (role_id, permission_id) VALUES -- 默认用户 (密码: admin123) INSERT INTO users (id, username, password_hash, display_name, department_id, position, status) VALUES - ('30000000-0000-0000-0000-000000000001', 'admin', '$2b$12$LJ3m4ys3Lk0TSwHCpNqrAODgL4A.Y6FuRzOEDx4eCEoQIq.Z/EZ2y', '系统管理员', '00000000-0000-0000-0000-000000000001', '管理员', 'active'); + ('30000000-0000-0000-0000-000000000001', 'admin', '$2b$12$0G/3v9vN3aJP3eGoqEse/uqyNxj6iigyGkUnZyndRN4ZURo9lDm/2', '系统管理员', '00000000-0000-0000-0000-000000000001', '管理员', 'active'); INSERT INTO user_roles (user_id, role_id) VALUES ('30000000-0000-0000-0000-000000000001', '10000000-0000-0000-0000-000000000001');