fix: 修复了严重bug
This commit is contained in:
parent
913648a071
commit
dc1c440703
|
|
@ -17,6 +17,8 @@ from sqlmodel import select
|
|||
from pretor.utils.error import UserNotExistError, UserPasswordError
|
||||
from pretor.core.database.database_exception import database_exception
|
||||
from pretor.core.database.table.user import UserAuthority
|
||||
from pretor.utils.access import Accessor
|
||||
|
||||
class AuthDatabase:
|
||||
def __init__(self, async_session_maker):
|
||||
self.async_session_maker = async_session_maker
|
||||
|
|
@ -53,7 +55,7 @@ class AuthDatabase:
|
|||
user = results.scalar_one_or_none()
|
||||
if user is None:
|
||||
raise UserNotExistError()
|
||||
if old_password != user.hashed_password:
|
||||
if not Accessor.verify_password(old_password, user.hashed_password):
|
||||
raise UserPasswordError()
|
||||
user.hashed_password = new_password
|
||||
session.add(user)
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class WorkerIndividual(SQLModel, table=True):
|
|||
description: str = Field(nullable=False)
|
||||
provider_title: str
|
||||
model_id: str
|
||||
system_prompt: Optional[dict]
|
||||
system_prompt: Optional[str]
|
||||
output_template: Optional[dict] = Field(sa_column=Column(JSON),description="输出模板标识")
|
||||
bound_skill: Optional[str] = Field(sa_column=Column(JSON))
|
||||
workspace: Optional[List[str]] = Field(sa_column=Column(JSON))
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class ControlNode:
|
|||
f"=== 当前任务步骤上下文 ===\n"
|
||||
f"- 步骤名称 (Name): {ctx.deps.workflow_step.name}\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
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ class Accessor:
|
|||
return jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM)
|
||||
|
||||
@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)
|
||||
|
||||
@staticmethod
|
||||
|
|
@ -84,7 +84,7 @@ class Accessor:
|
|||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="用户不存在",
|
||||
)
|
||||
if not Accessor._verify_password(password, user.hashed_password):
|
||||
if not Accessor.verify_password(password, user.hashed_password):
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_401_UNAUTHORIZED,
|
||||
detail="用户名或密码错误",
|
||||
|
|
|
|||
Loading…
Reference in New Issue