diff --git a/api/controllers/console/app/app.py b/api/controllers/console/app/app.py index 36338cbd8a..e8678c461a 100644 --- a/api/controllers/console/app/app.py +++ b/api/controllers/console/app/app.py @@ -9,6 +9,7 @@ from controllers.console.app.wraps import get_app_model from controllers.console.wraps import ( account_initialization_required, cloud_edition_billing_resource_check, + enterprise_license_required, setup_required, ) from core.ops.ops_trace_manager import OpsTraceManager @@ -28,6 +29,7 @@ class AppListApi(Resource): @setup_required @login_required @account_initialization_required + @enterprise_license_required def get(self): """Get app list""" diff --git a/api/controllers/console/workspace/account.py b/api/controllers/console/workspace/account.py index 823341ec42..aabc417759 100644 --- a/api/controllers/console/workspace/account.py +++ b/api/controllers/console/workspace/account.py @@ -14,7 +14,7 @@ from controllers.console.workspace.error import ( InvalidInvitationCodeError, RepeatPasswordNotMatchError, ) -from controllers.console.wraps import account_initialization_required, enterprise_license_required, setup_required +from controllers.console.wraps import account_initialization_required, setup_required from extensions.ext_database import db from fields.member_fields import account_fields from libs.helper import TimestampField, timezone @@ -78,7 +78,6 @@ class AccountProfileApi(Resource): @setup_required @login_required @account_initialization_required - @enterprise_license_required @marshal_with(account_fields) def get(self): return current_user diff --git a/api/controllers/console/workspace/error.py b/api/controllers/console/workspace/error.py index 5fbefd0cc5..07a47e5e3b 100644 --- a/api/controllers/console/workspace/error.py +++ b/api/controllers/console/workspace/error.py @@ -37,7 +37,7 @@ class AccountNotInitializedError(BaseHTTPException): code = 400 -class EnterpriseLicenseUnauthorized(BaseHTTPException): - error_code = "unauthorized" - description = "Your license is invalid. Please contact your administrator." +class UnauthorizedAndForceLogout(BaseHTTPException): + error_code = "unauthorized_and_force_logout" + description = "Unauthorized and force logout." code = 401 diff --git a/api/controllers/console/wraps.py b/api/controllers/console/wraps.py index 55e46681b0..9f8904deeb 100644 --- a/api/controllers/console/wraps.py +++ b/api/controllers/console/wraps.py @@ -6,7 +6,7 @@ from flask import abort, request from flask_login import current_user from configs import dify_config -from controllers.console.workspace.error import AccountNotInitializedError, EnterpriseLicenseUnauthorized +from controllers.console.workspace.error import AccountNotInitializedError, UnauthorizedAndForceLogout from models.model import DifySetup from services.feature_service import FeatureService, LicenseStatus from services.operation_service import OperationService @@ -149,7 +149,7 @@ def enterprise_license_required(view): def decorated(*args, **kwargs): settings = FeatureService.get_system_features() if settings.license.status in [LicenseStatus.INACTIVE, LicenseStatus.EXPIRED, LicenseStatus.LOST]: - raise EnterpriseLicenseUnauthorized() + raise UnauthorizedAndForceLogout("Your license is invalid. Please contact your administrator.") return view(*args, **kwargs)