From 73c4d4b07c0895be13669d0286f40de1ac0be65b Mon Sep 17 00:00:00 2001 From: jyong Date: Tue, 2 Apr 2024 17:45:20 +0800 Subject: [PATCH] Forbidden error --- api/controllers/console/wraps.py | 4 ++-- api/controllers/service_api/wraps.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/controllers/console/wraps.py b/api/controllers/console/wraps.py index 668d76461eff5..7c8ad110784ee 100644 --- a/api/controllers/console/wraps.py +++ b/api/controllers/console/wraps.py @@ -85,7 +85,7 @@ 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): @@ -93,7 +93,7 @@ def decorated(*args, **kwargs): 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) diff --git a/api/controllers/service_api/wraps.py b/api/controllers/service_api/wraps.py index 2529b5fb8c3d4..cb684cfac2064 100644 --- a/api/controllers/service_api/wraps.py +++ b/api/controllers/service_api/wraps.py @@ -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 @@ -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) @@ -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)