Skip to content

Commit

Permalink
Forbidden error
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnJyong committed Apr 2, 2024
1 parent db92490 commit 73c4d4b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api/controllers/console/wraps.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ def decorated(*args, **kwargs):


def cloud_edition_billing_knowledge_limit_check(resource: str,
error_msg: str = "You have reached the limit of your subscription."):
error_msg: str = "To unlock this feature and elevate your Dify experience, please upgrade to a paid plan."):
def interceptor(view):
@wraps(view)
def decorated(*args, **kwargs):
features = FeatureService.get_features(current_user.current_tenant_id)
if features.billing.enabled:
if resource == 'add_segment':
if features.billing.subscription.plan == 'sandbox':
abort(403, 'To unlock this feature and elevate your Dify experience, please upgrade to a paid plan.')
abort(403, error_msg)
else:
return view(*args, **kwargs)

Expand Down
12 changes: 6 additions & 6 deletions api/controllers/service_api/wraps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from flask_login import user_logged_in
from flask_restful import Resource
from pydantic import BaseModel
from werkzeug.exceptions import NotFound, Unauthorized
from werkzeug.exceptions import NotFound, Unauthorized, Forbidden

from extensions.ext_database import db
from libs.login import _get_user
Expand Down Expand Up @@ -92,13 +92,13 @@ def decorated(*args, **kwargs):
documents_upload_quota = features.documents_upload_quota

if resource == 'members' and 0 < members.limit <= members.size:
raise Unauthorized(error_msg)
raise Forbidden(error_msg)
elif resource == 'apps' and 0 < apps.limit <= apps.size:
raise Unauthorized(error_msg)
raise Forbidden(error_msg)
elif resource == 'vector_space' and 0 < vector_space.limit <= vector_space.size:
raise Unauthorized(error_msg)
raise Forbidden(error_msg)
elif resource == 'documents' and 0 < documents_upload_quota.limit <= documents_upload_quota.size:
raise Unauthorized(error_msg)
raise Forbidden(error_msg)
else:
return view(*args, **kwargs)

Expand All @@ -118,7 +118,7 @@ def decorated(*args, **kwargs):
if features.billing.enabled:
if resource == 'add_segment':
if features.billing.subscription.plan == 'sandbox':
raise Unauthorized(error_msg)
raise Forbidden(error_msg)
else:
return view(*args, **kwargs)

Expand Down

0 comments on commit 73c4d4b

Please sign in to comment.