From f05fc209b015e9d883566fc8cc4141dc9eff4db3 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 14 Jun 2019 12:01:55 +0100 Subject: Add a way to __or__ `utils.Check`s, as a "if one of these passes" thing --- modules/permissions/__init__.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'modules/permissions') diff --git a/modules/permissions/__init__.py b/modules/permissions/__init__.py index 3e2ce3f1..269f2a0f 100644 --- a/modules/permissions/__init__.py +++ b/modules/permissions/__init__.py @@ -191,14 +191,10 @@ class Module(ModuleManager.BaseModule): event["stdout"].write("Reset password for '%s'" % target.nickname) - @utils.hook("preprocess.command") - def preprocess_command(self, event): + def _check_command(self, event, permission, authenticated): if event["user"].admin_master: return utils.consts.PERMISSION_FORCE_SUCCESS - permission = event["hook"].get_kwarg("permission", None) - authenticated = event["hook"].kwargs.get("authenticated", False) - identity_mechanism = event["server"].get_setting("identity-mechanism", "internal") identified_account = None @@ -231,6 +227,16 @@ class Module(ModuleManager.BaseModule): else: return utils.consts.PERMISSION_FORCE_SUCCESS + @utils.hook("preprocess.command") + def preprocess_command(self, event): + permission = event["hook"].get_kwarg("permission", None) + authenticated = event["hook"].kwargs.get("authenticated", False) + return self._check_command(event, permission, authenticated) + + @utils.hook("check.command.permission") + def check_command(self, event): + return self._check_command(event, event["request_args"][0], False) + @utils.hook("received.command.mypermissions", authenticated=True) def my_permissions(self, event): """ -- cgit v1.3.1-10-gc9f91