| | |
| | | if db_user: |
| | | return Response(code=200, msg="Username already registered") |
| | | |
| | | bisheng_service = BishengService(settings.sgb_base_url) |
| | | # bisheng_service = BishengService(settings.sgb_base_url) |
| | | ragflow_service = RagflowService(settings.fwr_base_url) |
| | | |
| | | # 注册到毕昇 |
| | | try: |
| | | bisheng_info = await bisheng_service.register(user.username, user.password) |
| | | except Exception as e: |
| | | return Response(code=500, msg=f"Failed to register with Bisheng: {str(e)}") |
| | | # try: |
| | | # bisheng_info = await bisheng_service.register(user.username, user.password) |
| | | # except Exception as e: |
| | | # return Response(code=500, msg=f"Failed to register with Bisheng: {str(e)}") |
| | | |
| | | # 注册到ragflow |
| | | try: |
| | |
| | | |
| | | # 存储用户信息 |
| | | hashed_password = pwd_context.hash(user.password) |
| | | db_user = UserModel(username=user.username, hashed_password=hashed_password, email=ragflow_info.get("email", f"{user.username}@example.com"),ragflow_id=ragflow_info.get("id"),bisheng_id=bisheng_info.get("user_id")) |
| | | db_user = UserModel(username=user.username, hashed_password=hashed_password, email=ragflow_info.get("email", f"{user.username}@example.com"),ragflow_id=ragflow_info.get("id"),bisheng_id="") |
| | | db_user.password = db_user.encrypted_password(user.password) |
| | | db.add(db_user) |
| | | db.commit() |
| | |
| | | if not user: |
| | | return Response(code=400, msg="Incorrect username or password") |
| | | |
| | | bisheng_service = BishengService(settings.sgb_base_url) |
| | | # bisheng_service = BishengService(settings.sgb_base_url) |
| | | ragflow_service = RagflowService(settings.fwr_base_url) |
| | | |
| | | # 登录到毕昇 |
| | | try: |
| | | bisheng_token = await bisheng_service.login(login_data.username, login_data.password) |
| | | except Exception as e: |
| | | return Response(code=500, msg=f"Failed to login with Bisheng: {str(e)}") |
| | | # try: |
| | | # bisheng_token = await bisheng_service.login(login_data.username, login_data.password) |
| | | # except Exception as e: |
| | | # return Response(code=500, msg=f"Failed to login with Bisheng: {str(e)}") |
| | | |
| | | # 登录到ragflow |
| | | try: |
| | |
| | | # 创建本地token |
| | | access_token = create_access_token(data={"sub": user.username, "user_id": user.id}) |
| | | |
| | | upsert_token(db, user.id, access_token, bisheng_token, ragflow_token) |
| | | upsert_token(db, user.id, access_token, "bisheng_token", ragflow_token) |
| | | # print(111) |
| | | return Response(code=200, msg="Login successful", data={ |
| | | "access_token": access_token, |