| | |
| | | |
| | | 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 |
| | | |
| | | |
| | | async def get_user_list(db, page_index: int, page_size: int, keyword: str, role_key:str, user_id): |
| | |
| | | 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() |
| | | print(pwd) |
| | | print(new_password) |
| | | for app_type in AppRegister(db).get_app(): |
| | | if app_type == AgentType.RAGFLOW: |
| | | token = get_ragflow_token(db, user_id) |
| | | 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) |