fix: 修复了严重bug

This commit is contained in:
朝夕 2026-04-26 23:36:07 +08:00
parent 913648a071
commit dc1c440703
4 changed files with 7 additions and 5 deletions

View File

@ -17,6 +17,8 @@ from sqlmodel import select
from pretor.utils.error import UserNotExistError, UserPasswordError from pretor.utils.error import UserNotExistError, UserPasswordError
from pretor.core.database.database_exception import database_exception from pretor.core.database.database_exception import database_exception
from pretor.core.database.table.user import UserAuthority from pretor.core.database.table.user import UserAuthority
from pretor.utils.access import Accessor
class AuthDatabase: class AuthDatabase:
def __init__(self, async_session_maker): def __init__(self, async_session_maker):
self.async_session_maker = async_session_maker self.async_session_maker = async_session_maker
@ -53,7 +55,7 @@ class AuthDatabase:
user = results.scalar_one_or_none() user = results.scalar_one_or_none()
if user is None: if user is None:
raise UserNotExistError() raise UserNotExistError()
if old_password != user.hashed_password: if not Accessor.verify_password(old_password, user.hashed_password):
raise UserPasswordError() raise UserPasswordError()
user.hashed_password = new_password user.hashed_password = new_password
session.add(user) session.add(user)

View File

@ -30,7 +30,7 @@ class WorkerIndividual(SQLModel, table=True):
description: str = Field(nullable=False) description: str = Field(nullable=False)
provider_title: str provider_title: str
model_id: str model_id: str
system_prompt: Optional[dict] system_prompt: Optional[str]
output_template: Optional[dict] = Field(sa_column=Column(JSON),description="输出模板标识") output_template: Optional[dict] = Field(sa_column=Column(JSON),description="输出模板标识")
bound_skill: Optional[str] = Field(sa_column=Column(JSON)) bound_skill: Optional[str] = Field(sa_column=Column(JSON))
workspace: Optional[List[str]] = Field(sa_column=Column(JSON)) workspace: Optional[List[str]] = Field(sa_column=Column(JSON))

View File

@ -69,7 +69,7 @@ class ControlNode:
f"=== 当前任务步骤上下文 ===\n" f"=== 当前任务步骤上下文 ===\n"
f"- 步骤名称 (Name): {ctx.deps.workflow_step.name}\n" f"- 步骤名称 (Name): {ctx.deps.workflow_step.name}\n"
f"- 步骤目标/描述 (Description): {ctx.deps.workflow_step.desc}\n" f"- 步骤目标/描述 (Description): {ctx.deps.workflow_step.desc}\n"
f"- 前置输入input: {ctx.deps.workflow_step.input}\n" f"- 前置输入input: {ctx.deps.workflow_step.inputs}\n"
) )
return prompt return prompt

View File

@ -63,7 +63,7 @@ class Accessor:
return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM) return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
@staticmethod @staticmethod
def _verify_password(plain_password: str, hashed_password: str) -> bool: def verify_password(plain_password: str, hashed_password: str) -> bool:
return password_hasher.verify(plain_password, hashed_password) return password_hasher.verify(plain_password, hashed_password)
@staticmethod @staticmethod
@ -84,7 +84,7 @@ class Accessor:
status_code=status.HTTP_401_UNAUTHORIZED, status_code=status.HTTP_401_UNAUTHORIZED,
detail="用户不存在", detail="用户不存在",
) )
if not Accessor._verify_password(password, user.hashed_password): if not Accessor.verify_password(password, user.hashed_password):
raise HTTPException( raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED, status_code=status.HTTP_401_UNAUTHORIZED,
detail="用户名或密码错误", detail="用户名或密码错误",