fix: OAuth error when not allow register

This commit is contained in:
Joe
2024-09-09 17:27:40 +08:00
parent b46bb3e7a4
commit ef988371c7
3 changed files with 4 additions and 3 deletions

View File

@ -9,6 +9,7 @@ from werkzeug.exceptions import Unauthorized
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
@ -124,7 +125,7 @@ def _generate_account(provider: str, user_info: OAuthUserInfo):
if not account:
if not dify_config.ALLOW_REGISTER:
raise Unauthorized("Account not found")
raise NotAllowedRegister()
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