本文整理汇总了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"})
示例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()
示例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)