    async def init_blocked_users(self):
        """Revoke all permissions for users in Authenticator.blocked_users"""
        blocked_users = self.authenticator.blocked_users
        if not blocked_users:
            # nothing to check
            return
        db = self.db
        for user in db.query(orm.User).filter(orm.User.name.in_(blocked_users)):
            # revoke permissions from blocked users
            # so already-issued credentials have no access to the API
            self.log.debug(f"Found blocked user in database: {user.name}")
            if user.admin:
                self.log.warning(
                    f"Removing admin permissions from blocked user {user.name}"
                )
                user.admin = False
            if user.roles:
                self.log.warning(
                    f"Removing blocked user {user.name} from roles: {', '.join(role.name for role in user.roles)}"
                )
                user.roles = []
            if user.groups:
                self.log.warning(
                    f"Removing blocked user {user.name} from groups: {', '.join(group.name for group in user.groups)}"
                )
                user.groups = []

        db.commit()
Revoke all permissions for users in Authenticator.blocked_users
jupyterhub/app.py