Skip to content

Commit

Permalink
updated permission for anonymous poll
Browse files Browse the repository at this point in the history
  • Loading branch information
janhvipatil committed Apr 1, 2024
1 parent ab15acb commit c7b0232
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions raven/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@
permission_query_conditions = {
"Raven Channel": "raven.permissions.raven_channel_query",
"Raven Message": "raven.permissions.raven_message_query",
"Raven Poll Vote": "raven.permissions.raven_poll_vote_query",
}

has_permission = {
Expand Down
13 changes: 13 additions & 0 deletions raven/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,16 @@ def raven_message_query(user):
but needed for security since we do not want users to be able to view messages from channels they are not a member of
"""
return f"`tabRaven Message`.owner = {frappe.db.escape(user)}"


def raven_poll_vote_query(user):
if not user:
user = frappe.session.user

"""
Only show votes created by the user using a WHERE clause
Hence, we are adding a WHERE clause to the query - this is inconsequential since we will never use the standard get_list query for Raven Poll Vote,
but needed for security since we do not want users to be able to view votes from polls they did not vote for
"""
return f"`tabRaven Poll Vote`.owner = {frappe.db.escape(user)}"

0 comments on commit c7b0232

Please sign in to comment.