Skip to content

Commit

Permalink
Merge branch 'refs/heads/feat/new-login' into deploy/dev
Browse files Browse the repository at this point in the history
* refs/heads/feat/new-login:
  feat: remove extra judgement
  • Loading branch information
ZhouhaoJiang committed Sep 2, 2024
2 parents 2eee6f2 + f342995 commit bb5366c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 7 additions & 3 deletions api/controllers/console/auth/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import requests
from flask import current_app, redirect, request
from flask_restful import Resource
from werkzeug.exceptions import Unauthorized

import services
from configs import dify_config
from constants.languages import languages
from extensions.ext_database import db
Expand Down Expand Up @@ -80,8 +80,9 @@ def get(self, provider: str):

try:
account = _generate_account(provider, user_info)
except services.errors.account.AccountNotFound as e:
except Unauthorized:
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=AccountNotFound")

# Check account status
if account.status == AccountStatus.BANNED.value or account.status == AccountStatus.CLOSED.value:
return {"error": "Account is banned or closed."}, 403
Expand All @@ -91,7 +92,10 @@ def get(self, provider: str):
account.initialized_at = datetime.now(timezone.utc).replace(tzinfo=None)
db.session.commit()

TenantService.create_owner_tenant_if_not_exist(account)
try:
TenantService.create_owner_tenant_if_not_exist(account)
except Unauthorized:
return redirect(f"{dify_config.CONSOLE_WEB_URL}/signin?message=WorkspaceNotFound")

token = AccountService.login(account, ip_address=get_remote_ip(request))

Expand Down
3 changes: 0 additions & 3 deletions api/services/account_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ def create_tenant(name: str) -> Tenant:
@staticmethod
def create_owner_tenant_if_not_exist(account: Account):
"""Create owner tenant if not exist"""
if not dify_config.ALLOW_CREATE_WORKSPACE:
raise Unauthorized("Create workspace is not allowed.")

available_ta = (
TenantAccountJoin.query.filter_by(account_id=account.id).order_by(TenantAccountJoin.id.asc()).first()
)
Expand Down

0 comments on commit bb5366c

Please sign in to comment.