Skip to content

Commit

Permalink
Fix permission check in optout plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxdaemon committed Nov 14, 2017
1 parent 4c57f30 commit e1c5770
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions plugins/core/optout.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ def check_global_perms(event):

if chan.lower() == "global":
if not can_global:
event.notice("You do not have permission to view global opt outs")
return
event.notice("You do not have permission to access global opt outs")
allowed = False

chan = None

Expand All @@ -240,6 +240,9 @@ def list_optout(conn, event, async_call):
"""
chan, allowed = yield from check_global_perms(event)

if not allowed:
return

opts = yield from async_call(get_channel_optouts, conn.name, chan)
table = yield from async_call(format_optout_list, opts)

Expand All @@ -252,6 +255,9 @@ def clear(conn, event, db, async_call):
"""[channel] - Clears the optout list for a channel. Specify "global" to clear all data for this network"""
chan, allowed = yield from check_global_perms(event)

if not allowed:
return

count = yield from async_call(clear_optout, db, conn.name, chan)

return "Cleared {} opt outs from the list.".format(count)

0 comments on commit e1c5770

Please sign in to comment.