Skip to content

Commit

Permalink
fix: account check in runtime (langgenius#569)
Browse files Browse the repository at this point in the history
  • Loading branch information
takatost authored Jul 15, 2023
1 parent 171b7ce commit acb11a5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import os
from datetime import datetime

from werkzeug.exceptions import Forbidden

if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
from gevent import monkey
monkey.patch_all()
Expand All @@ -27,7 +29,7 @@
import core
from config import Config, CloudEditionConfig
from commands import register_commands
from models.account import TenantAccountJoin
from models.account import TenantAccountJoin, AccountStatus
from models.model import Account, EndUser, App

import warnings
Expand Down Expand Up @@ -101,6 +103,9 @@ def load_user(user_id):
account = db.session.query(Account).filter(Account.id == account_id).first()

if account:
if account.status == AccountStatus.BANNED.value or account.status == AccountStatus.CLOSED.value:
raise Forbidden('Account is banned or closed.')

workspace_id = session.get('workspace_id')
if workspace_id:
tenant_account_join = db.session.query(TenantAccountJoin).filter(
Expand Down

0 comments on commit acb11a5

Please sign in to comment.