Software /
code /
prosody-modules
Diff
mod_adhoc/adhoc/mod_adhoc.lua @ 49:59f490390528
mod_adhoc, mod_adhoc_cmd_admin: Check permissions in one place for all commands
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Sat, 17 Oct 2009 01:37:25 +0200 |
parent | 43:adc9eff8adb2 |
child | 93:611d16867410 |
line wrap: on
line diff
--- a/mod_adhoc/adhoc/mod_adhoc.lua Sat Oct 17 01:36:25 2009 +0200 +++ b/mod_adhoc/adhoc/mod_adhoc.lua Sat Oct 17 01:37:25 2009 +0200 @@ -34,6 +34,14 @@ local node = stanza.tags[1].attr.node for i = 1, #commands do if commands[i].node == node then + -- check whether user has permission to execute this command first + if commands[i].permission == "admin" and not is_admin(stanza.attr.from) then + origin.send(st.error_reply(stanza, "auth", "forbidden", "You don't have permission to execute this command"):up() + :add_child(commands[i]:cmdtag("canceled") + :tag("note", {type="error"}):text("You don't have permission to execute this command"))); + return true + end + -- User has permission now execute the command return commands[i].handler(commands[i], origin, stanza); end end