frappe / gameplan

Delightful, open-source, work communication tool for remote teams
https://frappe.io/gameplan
GNU Affero General Public License v3.0
305 stars 129 forks source link

fix: added app permission check for apps page #313

Closed shariquerik closed 3 months ago

shariquerik commented 3 months ago

Added has_permission to check if user has access to portal page

add_to_apps_screen = [
    {
        "name": "gameplan",
        "logo": "/assets/gameplan/manifest/favicon-196.png",
        "title": "Gameplan",
        "route": "/g",
        "has_permission": "gameplan.api.check_app_permission"
    }
]
def check_app_permission():
    if frappe.session.user == "Administrator":
        return True

    roles = frappe.get_roles()
    if any(role in ["System Manager", "Gameplan Admin", "Gameplan Member", "Gameplan Guest"] for role in roles):
        return True

    return False