From e8f8fb8a8f68f365a57f870697a5c81933d11c2c Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 30 Aug 2024 16:51:26 +0530 Subject: [PATCH 1/2] fix: added app permission check for apps page --- erpnext/__init__.py | 11 +++++++++++ erpnext/hooks.py | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index 7a8ff199c8f0..a636e9775c6b 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -2,6 +2,7 @@ import inspect import frappe +from frappe.utils.user import is_website_user __version__ = "16.0.0-dev" @@ -149,3 +150,13 @@ def caller(*args, **kwargs): return frappe.get_attr(overrides[function_path][-1])(*args, **kwargs) return caller + + +def check_app_permission(): + if frappe.session.user == "Administrator": + return True + + if is_website_user(): + return False + + return True \ No newline at end of file diff --git a/erpnext/hooks.py b/erpnext/hooks.py index edbded6d436d..bd0eb4a0764d 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -16,7 +16,7 @@ "logo": "/assets/erpnext/images/erpnext-logo-blue.png", "title": "ERPNext", "route": "/app/home", - # "has_permission": "erpnext.api.permission.has_app_permission" + "has_permission": "erpnext.check_app_permission" } ] From 1d9ed27a89fcbe77c86b8fc18940e26fc3b255ac Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Fri, 30 Aug 2024 16:57:17 +0530 Subject: [PATCH 2/2] chore: linter fix --- erpnext/__init__.py | 2 +- erpnext/hooks.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/erpnext/__init__.py b/erpnext/__init__.py index a636e9775c6b..e3c350163128 100644 --- a/erpnext/__init__.py +++ b/erpnext/__init__.py @@ -159,4 +159,4 @@ def check_app_permission(): if is_website_user(): return False - return True \ No newline at end of file + return True diff --git a/erpnext/hooks.py b/erpnext/hooks.py index bd0eb4a0764d..aa382d227cba 100644 --- a/erpnext/hooks.py +++ b/erpnext/hooks.py @@ -16,7 +16,7 @@ "logo": "/assets/erpnext/images/erpnext-logo-blue.png", "title": "ERPNext", "route": "/app/home", - "has_permission": "erpnext.check_app_permission" + "has_permission": "erpnext.check_app_permission", } ]