def __call__(self, *args): """Verify the player's authorization.""" # Does the player's authorization need to be checked? if self.check_auth: # Is the player authorized? if not auth_manager.is_player_authorized( playerinfo_from_index(args[1]), self.level, self.permission, self.flag): # Is there fail callback? if self.fail_callback is not None: # Use try/except in case the fail # callback encounters an error try: # Call the fail callback self.fail_callback(*args) # Was an error encountered? except: # Print the exception to the console except_hooks.print_exception() # Return a False value, since the player is not authorized return False # Call the callback and return its value return self.callback(*args)
def on_clean_command(cls, command_info, command_node, args): if (command_node.permission is None or auth_manager.is_player_authorized( command_info.index, command_node.permission)): return super().on_clean_command(command_info, command_node, args) return cls.handle_fail_callback(command_info, command_node, args)
def is_authorized_to_bypass(self, player_class): permission = (BYPASS_PERMISSION_BASE + '.' + CLASS_NAME_BY_ID[player_class]) return auth_manager.is_player_authorized(self.player.index, permission)
def has_permission(self, permission): return auth_manager.is_player_authorized(self.player.index, permission)