fix: oauth error when not allowed create workspace

fix: oauth error when not allowed create workspace
This commit is contained in:
Joe
2024-09-09 18:19:55 +08:00
parent 358a5f61d3
commit 4893631d65
3 changed files with 18 additions and 10 deletions

View File

@ -15,6 +15,7 @@ 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 services.errors.workspace import WorkSpaceNotAllowedCreateError
from .. import api
@ -90,6 +91,10 @@ class OAuthCallback(Resource):
account = _generate_account(provider, user_info)
except AccountNotFound:
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=AccountNotFound")
except WorkSpaceNotAllowedCreateError:
return redirect(
f"{dify_config.CONSOLE_WEB_URL}/signin?message=Workspace not found, please contact system admin to invite you to join in a workspace."
)
# Check account status
if account.status == AccountStatus.BANNED.value or account.status == AccountStatus.CLOSED.value: