Skip to content

Commit

Permalink
fix: tickets: perms: allow if owner
Browse files Browse the repository at this point in the history
  • Loading branch information
ssiyad committed Oct 11, 2023
1 parent 75627e6 commit 2b40ba5
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions helpdesk/helpdesk/doctype/hd_ticket/hd_ticket.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,14 @@ def on_communication_update(self, c):
self.save()


def has_permission(doc):
user = frappe.session.user
customer = get_customer(user)
is_customer = doc.customer == customer
is_contact = doc.contact == user
is_raised = doc.raised_by == user
has_extra_permissions = is_customer or is_contact or is_raised or is_agent()
return has_extra_permissions
# Check if `user` has access to this specific ticket (`doc`). This implements extra
# permission checks which is not possible with standard permission system. This function
# is being called from hooks. `doc` is the ticket to check against
def has_permission(doc, user=None):
return (
doc.contact == user
or doc.raised_by == user
or doc.owner == user
or doc.customer == get_customer(user)
or is_agent()
)

0 comments on commit 2b40ba5

Please sign in to comment.