Skip to content

Commit

Permalink
fix: added app permission check for apps page
Browse files Browse the repository at this point in the history
  • Loading branch information
shariquerik committed Aug 30, 2024
1 parent 0edde76 commit 782761e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions crm/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import frappe
from frappe.translate import get_all_translations
from frappe.utils import cstr
from frappe.utils.telemetry import POSTHOG_HOST_FIELD, POSTHOG_PROJECT_FIELD


@frappe.whitelist(allow_guest=True)
Expand Down Expand Up @@ -47,11 +46,13 @@ def get_user_signature():
content = f'<br><p class="signature">{signature}</p>'
return content

@frappe.whitelist()
def get_posthog_settings():
return {
"posthog_project_id": frappe.conf.get(POSTHOG_PROJECT_FIELD),
"posthog_host": frappe.conf.get(POSTHOG_HOST_FIELD),
"enable_telemetry": frappe.get_system_settings("enable_telemetry"),
"telemetry_site_age": frappe.utils.telemetry.site_age(),
}

def check_app_permission():
if frappe.session.user == "Administrator":
return True

roles = frappe.get_roles()
if any(role in ["System Manager", "Sales User", "Sales Manager", "Sales Master Manager"] for role in roles):
return True

return False
2 changes: 1 addition & 1 deletion crm/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"logo": "/assets/crm/manifest/apple-icon-180.png",
"title": "CRM",
"route": "/crm",
# "has_permission": "crm.api.permission.has_app_permission"
"has_permission": "crm.api.check_app_permission"
}
]

Expand Down

0 comments on commit 782761e

Please sign in to comment.