Skip to content

Commit

Permalink
Merge branch 'feat/new-login' into deploy/dev
Browse files Browse the repository at this point in the history
* feat/new-login:
  feat: add workspace not found
  • Loading branch information
ZhouhaoJiang committed Sep 10, 2024
2 parents 6ec4bc4 + 57a2534 commit eb75dfc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
9 changes: 8 additions & 1 deletion api/controllers/console/auth/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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 services.errors.workspace import WorkSpaceNotAllowedCreateError, WorkSpaceNotFound

from .. import api

Expand Down Expand Up @@ -91,6 +91,8 @@ def get(self, provider: str):
account = _generate_account(provider, user_info)
except AccountNotFound:
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=AccountNotFound")
except WorkSpaceNotFound:
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=WorkspaceNotFound")
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."
Expand Down Expand Up @@ -128,6 +130,11 @@ def _generate_account(provider: str, user_info: OAuthUserInfo):
# Get account by openid or email.
account = _get_account_by_openid_or_email(provider, user_info)

if account:
tenant = TenantService.get_join_tenants(account)
if not tenant:
raise WorkSpaceNotFound()

if not account:
if not dify_config.ALLOW_REGISTER:
raise AccountNotFound()
Expand Down
4 changes: 4 additions & 0 deletions api/services/errors/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@

class WorkSpaceNotAllowedCreateError(BaseServiceError):
pass


class WorkSpaceNotFound(BaseServiceError):
pass

0 comments on commit eb75dfc

Please sign in to comment.