当前位置: 首页>>代码示例>>Python>>正文


Python Authentication.list_users方法代码示例

本文整理汇总了Python中authentication.Authentication.list_users方法的典型用法代码示例。如果您正苦于以下问题:Python Authentication.list_users方法的具体用法?Python Authentication.list_users怎么用?Python Authentication.list_users使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在authentication.Authentication的用法示例。


在下文中一共展示了Authentication.list_users方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import list_users [as 别名]

#.........这里部分代码省略.........
        err = self.authentication.get_error()
        if err is None:
            # We need a JSON string for javascript
            plugin_strings = []
            for plugin in roles_list.keys():
                roles = roles_list[plugin]
                if len(roles) > 0:
                    plugin_strings.append("'" + plugin + "' : ['" + "','".join(roles) + "']")
                else:
                    plugin_strings.append("'" + plugin + "' : []")
            responseMessage = "{" + ",".join(plugin_strings) + "}"
            self.writer.println(responseMessage)
            self.writer.close()

        else:
            self.throw_error(err)

    def grant_access(self):
        record = formData.get("record")
        role   = formData.get("role")
        source = formData.get("source")
        self.authentication.set_access_plugin(source)
        self.authentication.grant_access(record, role)

        err = self.authentication.get_error()
        if err is None:
            self.writer.println(role)
            self.writer.close()
            self.reindex_record(record)

        else:
            self.throw_error(err)

    def list_users(self):
        rolename = formData.get("rolename")
        source = formData.get("source")
        self.authentication.set_auth_plugin(source)
        user_list = self.authentication.list_users(rolename)

        err = self.authentication.get_error()
        if err is None:
            # We need a JSON string for javascript
            responseMessage = "{['" + "','".join(user_list) + "']}"
            self.writer.println(responseMessage)
            self.writer.close()

        else:
            self.throw_error(err)

    def process(self):
        action = formData.get("verb")

        switch = {
            "add-user"           : self.add_user,
            "confirm-message"    : self.confirm_message,
            "create-role"        : self.create_role,
            "create-user"        : self.create_user,
            "delete-role"        : self.delete_role,
            "delete-user"        : self.delete_user,
            "change-password"    : self.change_password,
            "get-current-access" : self.get_current_access,
            "grant-access"       : self.grant_access,
            "list-users"         : self.list_users,
            "remove-user"        : self.remove_user,
            "revoke-access"      : self.revoke_access
        }
开发者ID:kiranba,项目名称:the-fascinator,代码行数:70,代码来源:admin.py

示例2: __init__

# 需要导入模块: from authentication import Authentication [as 别名]
# 或者: from authentication.Authentication import list_users [as 别名]

#.........这里部分代码省略.........
        password = formData.get("password")
        password_confirm = formData.get("password_confirm")

        if password != password_confirm:
            self.throw_error("The confirm password field does not match the password.")

        else:
            source = formData.get("source")
            self.authentication.set_auth_plugin(source)
            self.authentication.create_user(username, password)

            err = self.authentication.get_error()
            if err is None:
                self.writer.println(username)
                self.writer.close()

            else:
                self.throw_error(err)

    def delete_role(self):
        rolename = formData.get("rolename")
        source = formData.get("source")
        self.authentication.set_role_plugin(source)
        self.authentication.delete_role(rolename)

        err = self.authentication.get_error()
        if err is None:
            self.writer.println(rolename)
            self.writer.close()

        else:
            self.throw_error(err)

    def delete_user(self):
        username = formData.get("username")
        source = formData.get("source")
        self.authentication.set_auth_plugin(source)
        self.authentication.delete_user(username)

        err = self.authentication.get_error()
        if err is None:
            self.writer.println(username)
            self.writer.close()

        else:
            self.throw_error(err)

    def list_users(self):
        rolename = formData.get("rolename")
        source = formData.get("source")
        self.authentication.set_auth_plugin(source)
        user_list = self.authentication.list_users(rolename)

        err = self.authentication.get_error()
        if err is None:
            # We need a JSON string for javascript
            responseMessage = "{['" + "','".join(user_list) + "']}"
            self.writer.println(responseMessage)
            self.writer.close()

        else:
            self.throw_error(err)

    def process(self):
        action = formData.get("verb")

        switch = {
            "add-user"        : self.add_user,
            "create-role"     : self.create_role,
            "create-user"     : self.create_user,
            "delete-role"     : self.delete_role,
            "delete-user"     : self.delete_user,
            "change-password" : self.change_password,
            "list-users"      : self.list_users,
            "remove-user"     : self.remove_user
        }
        switch.get(action, self.unknown_action)()

    def remove_user(self):
        username = formData.get("username")
        rolename = formData.get("rolename")
        source = formData.get("source")
        self.authentication.set_role_plugin(source)
        self.authentication.remove_role(username, rolename)

        err = self.authentication.get_error()
        if err is None:
            self.writer.println(username)
            self.writer.close()

        else:
            self.throw_error(err)

    def throw_error(self, message):
        response.setStatus(500)
        self.writer.println("Error: " + message)
        self.writer.close()

    def unknown_action(self):
        self.throw_error("Unknown action requested - '" + formData.get("verb") + "'")
开发者ID:kiranba,项目名称:the-fascinator,代码行数:104,代码来源:admin.py


注:本文中的authentication.Authentication.list_users方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。