Skip to content

Commit

Permalink
Merge branch 'license-verify-status' into license-testing
Browse files Browse the repository at this point in the history
  • Loading branch information
GarfieldDai committed Nov 13, 2024
2 parents 1c97bbc + 0ef37de commit b2570c2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions api/controllers/console/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
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
Expand All @@ -28,6 +29,7 @@ class AppListApi(Resource):
@setup_required
@login_required
@account_initialization_required
@enterprise_license_required
def get(self):
"""Get app list"""

Expand Down
3 changes: 1 addition & 2 deletions api/controllers/console/workspace/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions api/controllers/console/workspace/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions api/controllers/console/wraps.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit b2570c2

Please sign in to comment.