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


Python User.update_user_info方法代码示例

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


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

示例1: test_13_update_user

# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import update_user_info [as 别名]
    def test_13_update_user(self):
        realm = "sqlrealm"
        resolver = "SQL1"
        parameters = self.parameters
        parameters["resolver"] = resolver
        parameters["type"] = "sqlresolver"

        rid = save_resolver(parameters)
        self.assertTrue(rid > 0, rid)

        (added, failed) = set_realm(realm, [resolver])
        self.assertEqual(len(failed), 0)
        self.assertEqual(len(added), 1)

        user = User(login="wordpressuser", realm=realm)
        uinfo = user.info
        self.assertEqual(uinfo.get("givenname", ""), "")

        user.update_user_info({"givenname": "wordy",
                               "username": "WordpressUser"})
        uinfo = user.info
        self.assertEqual(uinfo.get("givenname"), "wordy")

        self.assertEqual(user.login, "WordpressUser")

        user.update_user_info({"givenname": "",
                               "username": "wordpressuser"})
开发者ID:MWelp,项目名称:privacyidea,代码行数:29,代码来源:test_lib_user.py

示例2: test_09_invalidate_edit_user

# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import update_user_info [as 别名]
    def test_09_invalidate_edit_user(self):
        # Validate that editing users actually invalidates the cache. For that, we first need an editable resolver
        self._create_sql_realm()
        # The cache is initially empty
        self.assertEquals(UserCache.query.count(), 0)
        # The following adds an entry to the cache
        user = User(login="wordpressuser", realm=self.sql_realm)
        self.assertEquals(UserCache.query.count(), 1)
        uinfo = user.info
        self.assertEqual(uinfo.get("givenname", ""), "")

        user.update_user_info({"givenname": "wordy"})
        uinfo = user.info
        self.assertEqual(uinfo.get("givenname"), "wordy")
        # This should have removed the entry from the cache
        self.assertEqual(UserCache.query.count(), 0)
        # But now it gets added again
        user2 = User(login="wordpressuser", realm=self.sql_realm)
        self.assertEqual(UserCache.query.count(), 1)
        # Change it back for the other tests
        user.update_user_info({"givenname": ""})
        uinfo = user.info
        self.assertEqual(uinfo.get("givenname", ""), "")
        self.assertEqual(UserCache.query.count(), 0)
        self._delete_sql_realm()
开发者ID:STRML,项目名称:privacyidea,代码行数:27,代码来源:test_lib_usercache.py

示例3: update_user

# 需要导入模块: from privacyidea.lib.user import User [as 别名]
# 或者: from privacyidea.lib.user.User import update_user_info [as 别名]
def update_user():
    """
    Edit a user in the user store.
    The resolver must have the flag editable, so that the user can be deleted.
    Only administrators are allowed to edit users.

    **Example request**:

    .. sourcecode:: http

       PUT /user
       user=existing_user
       resolver=<resolvername>
       surname=...
       givenname=...
       email=...
       mobile=...
       phone=...
       password=...
       description=...

       Host: example.com
       Accept: application/json

    .. note:: Also a user can call this function to e.g. change his password.
       But in this case the parameter "user" and "resolver" get overwritten
       by the values of the authenticated user, even if he specifies another
       username.
    """
    attributes = _get_attributes_from_param(request.all_data)
    username = getParam(request.all_data, "user", optional=False)
    resolvername = getParam(request.all_data, "resolver", optional=False)
    user_obj = User(login=username, resolver=resolvername)
    # Remove the password from the attributes, so that we can hide it in the
    # logs
    password = attributes.get("password")
    if password:
        del attributes["password"]
    r = user_obj.update_user_info(attributes, password=password)
    g.audit_object.log({"success": True,
                        "info": u"{0!s}: {1!s}/{2!s}".format(r, username, resolvername)})
    return send_result(r)
开发者ID:STRML,项目名称:privacyidea,代码行数:44,代码来源:user.py


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