mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-11 05:59:01 +08:00
fix: account check in runtime (#569)
This commit is contained in:
parent
20514ff288
commit
24f3456990
@ -2,6 +2,8 @@
|
|||||||
import os
|
import os
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
from werkzeug.exceptions import Forbidden
|
||||||
|
|
||||||
if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
|
if not os.environ.get("DEBUG") or os.environ.get("DEBUG").lower() != 'true':
|
||||||
from gevent import monkey
|
from gevent import monkey
|
||||||
monkey.patch_all()
|
monkey.patch_all()
|
||||||
@ -27,7 +29,7 @@ from events import event_handlers
|
|||||||
import core
|
import core
|
||||||
from config import Config, CloudEditionConfig
|
from config import Config, CloudEditionConfig
|
||||||
from commands import register_commands
|
from commands import register_commands
|
||||||
from models.account import TenantAccountJoin
|
from models.account import TenantAccountJoin, AccountStatus
|
||||||
from models.model import Account, EndUser, App
|
from models.model import Account, EndUser, App
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
@ -101,6 +103,9 @@ def load_user(user_id):
|
|||||||
account = db.session.query(Account).filter(Account.id == account_id).first()
|
account = db.session.query(Account).filter(Account.id == account_id).first()
|
||||||
|
|
||||||
if account:
|
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')
|
workspace_id = session.get('workspace_id')
|
||||||
if workspace_id:
|
if workspace_id:
|
||||||
tenant_account_join = db.session.query(TenantAccountJoin).filter(
|
tenant_account_join = db.session.query(TenantAccountJoin).filter(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user