From 358a5f61d36bf7ce5a73134d2e447cb473161270 Mon Sep 17 00:00:00 2001 From: Joe <1264204425@qq.com> Date: Mon, 9 Sep 2024 17:44:50 +0800 Subject: [PATCH] feat: add OAuthCallback redirect --- api/controllers/console/auth/oauth.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/controllers/console/auth/oauth.py b/api/controllers/console/auth/oauth.py index e387cf22a371d5..2e0eeb2895899c 100644 --- a/api/controllers/console/auth/oauth.py +++ b/api/controllers/console/auth/oauth.py @@ -9,12 +9,12 @@ from configs import dify_config from constants.languages import languages -from controllers.console.error import NotAllowedRegister from extensions.ext_database import db from libs.helper import get_remote_ip from libs.oauth import GitHubOAuth, GoogleOAuth, OAuthUserInfo from models.account import Account, AccountStatus from services.account_service import AccountService, RegisterService, TenantService +from services.errors.account import AccountNotFound from .. import api @@ -88,7 +88,7 @@ def get(self, provider: str): try: account = _generate_account(provider, user_info) - except Unauthorized: + except AccountNotFound: return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=AccountNotFound") # Check account status @@ -125,7 +125,7 @@ def _generate_account(provider: str, user_info: OAuthUserInfo): if not account: if not dify_config.ALLOW_REGISTER: - raise NotAllowedRegister() + raise AccountNotFound() account_name = user_info.name if user_info.name else "Dify" account = RegisterService.register( email=user_info.email, name=account_name, password=None, open_id=user_info.id, provider=provider