fix: OAuth error when not allow register
This commit is contained in:
parent
b46bb3e7a4
commit
ef988371c7
@ -42,7 +42,7 @@ class LoginApi(Resource):
|
||||
raise PasswordMismatchError()
|
||||
except services.errors.account.AccountNotFound:
|
||||
if not dify_config.ALLOW_REGISTER:
|
||||
raise NotAllowedCreateWorkspace()
|
||||
raise NotAllowedRegister()
|
||||
|
||||
token = AccountService.send_reset_password_email(email=args["email"])
|
||||
return {"result": "fail", "data": token, "message": "account_not_found"}
|
||||
|
@ -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
|
||||
|
@ -51,4 +51,4 @@ class NotAllowedCreateWorkspace(BaseHTTPException):
|
||||
class NotAllowedRegister(BaseHTTPException):
|
||||
error_code = "unauthorized"
|
||||
description = "Account not found."
|
||||
code = 404
|
||||
code = 400
|
||||
|
Loading…
Reference in New Issue
Block a user