From 5580958d49e5aab48908000614e47ecb75ff4797 Mon Sep 17 00:00:00 2001
From: zhaoqingang <zhaoqg0118@163.com>
Date: 星期四, 28 十一月 2024 19:14:26 +0800
Subject: [PATCH] 智能数据问题优化
---
app/service/user.py | 25 ++++++++++++++++++++-----
1 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/app/service/user.py b/app/service/user.py
index c11a386..f5cc7ea 100644
--- a/app/service/user.py
+++ b/app/service/user.py
@@ -2,11 +2,13 @@
from app.api import pwd_context
from app.config.config import settings
-from app.models import RoleModel, GroupModel
+from app.models import RoleModel, GroupModel, AgentType
from app.models.user_model import UserModel
from Log import logger
from app.service.bisheng import BishengService
+from app.service.common.app_register import AppRegister
from app.service.ragflow import RagflowService
+from app.service.service_token import get_ragflow_token, get_bisheng_token, get_ragflow_new_token
async def get_user_list(db, page_index: int, page_size: int, keyword: str, role_key:str, user_id):
@@ -98,12 +100,25 @@
return True
-async def edit_user_pwd(db, user_id, password="000000"):
+async def edit_user_pwd(db, user_id, current_user_id ,new_password="000000"):
try:
- #TODO
- hashed_password = pwd_context.hash(password)
user = db.query(UserModel).filter(UserModel.id == user_id).first()
- user.hashed_password = hashed_password
+ pwd = user.decrypted_password()
+ for app_type in AppRegister(db).get_app():
+ if app_type == AgentType.RAGFLOW:
+ token = await get_ragflow_new_token(db, user_id, app_type)
+ ragflow_service = RagflowService(settings.fwr_base_url)
+ await ragflow_service.set_user_password(token, pwd, new_password)
+ elif app_type == AgentType.BISHENG:
+ token = get_bisheng_token(db, current_user_id)
+ bisheng_service = BishengService(settings.sgb_base_url)
+ await bisheng_service.change_password_public(token, user.username, pwd, new_password)
+ else:
+ logger.error("娉ㄥ唽鏈煡搴旂敤锛歿}".format(app_type))
+ # hashed_password = pwd_context.hash(password)
+ hashed_password = user.encrypted_password(new_password)
+
+ user.password = hashed_password
db.commit()
except Exception as e:
logger.error(e)
--
Gitblit v1.8.0