get user permissions every time they try to use a command that requires
permissions, instead of caching their permissions when they sign in
This commit is contained in:
parent
1c50a27564
commit
84ea92fea8
1 changed files with 8 additions and 6 deletions
|
@ -42,11 +42,9 @@ class Module(object):
|
|||
|
||||
def _identified(self, user):
|
||||
user.identified = True
|
||||
user.permissions = user.get_setting("permissions", [])
|
||||
|
||||
def _logout(self, user):
|
||||
user.identified = False
|
||||
user.permissions = []
|
||||
|
||||
def identify(self, event):
|
||||
if not event["user"].channels:
|
||||
|
@ -89,10 +87,14 @@ class Module(object):
|
|||
|
||||
def preprocess_command(self, event):
|
||||
permission = event["hook"].kwargs.get("permission", None)
|
||||
if permission and not permission in event["user"
|
||||
].permissions and not "*" in event["user"].permissions:
|
||||
if permission:
|
||||
identified = event["user"].identified
|
||||
user_permissions = event["user"].get_setting("permissions", [])
|
||||
has_permission = permission and (
|
||||
permission in user_permissions or "*" in user_permissions)
|
||||
if not identified or not has_permission:
|
||||
return "You do not have permission to do that"
|
||||
|
||||
def my_permissions(self, event):
|
||||
permissions = event["user"].permissions
|
||||
permissions = event["user"].get_setting("permissions", [])
|
||||
event["stdout"].write("Your permissions: %s" % ", ".join(permissions))
|
||||
|
|
Loading…
Reference in a new issue