diff options
| author | 2019-06-14 12:01:55 +0100 | |
|---|---|---|
| committer | 2019-06-14 12:01:55 +0100 | |
| commit | f05fc209b015e9d883566fc8cc4141dc9eff4db3 (patch) | |
| tree | 599c4bb8f31e22af304c3b8f20977738b9b55649 /modules/permissions | |
| parent | Catch `yield`s in command callbacks for e.g. permission checks (diff) | |
| signature | ||
Add a way to __or__ `utils.Check`s, as a "if one of these passes" thing
Diffstat (limited to 'modules/permissions')
| -rw-r--r-- | modules/permissions/__init__.py | 16 |
1 files changed, 11 insertions, 5 deletions
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): """ |
