本文整理汇总了Python中tracim_backend.lib.core.user.UserApi.set_password方法的典型用法代码示例。如果您正苦于以下问题:Python UserApi.set_password方法的具体用法?Python UserApi.set_password怎么用?Python UserApi.set_password使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim_backend.lib.core.user.UserApi
的用法示例。
在下文中一共展示了UserApi.set_password方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unit__create_minimal_user_and_set_password__ok__nominal_case
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import set_password [as 别名]
def test_unit__create_minimal_user_and_set_password__ok__nominal_case(self):
u = User()
u.email = '[email protected]'
u.password = 'pass'
u.auth_type = AuthType.INTERNAL
u.display_name = 'bob'
api = UserApi(
current_user=u,
session=self.session,
config=self.app_config,
)
assert u.validate_password('pass')
api.set_password(u,'pass','newpass','newpass')
assert u is not None
assert u.email == '[email protected]'
assert u.display_name == 'bob'
assert u.validate_password('newpass')
assert not u.validate_password('pass')
示例2: set_account_password
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import set_password [as 别名]
def set_account_password(self, context, request: TracimRequest, hapic_data=None): # nopep8
"""
Set user password
"""
app_config = request.registry.settings['CFG']
uapi = UserApi(
current_user=request.current_user, # User
session=request.dbsession,
config=app_config,
)
uapi.set_password(
request.current_user,
hapic_data.body.loggedin_user_password,
hapic_data.body.new_password,
hapic_data.body.new_password2,
do_save=True
)
return
示例3: test_unit_set_password__err__external_auth_ldap
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import set_password [as 别名]
def test_unit_set_password__err__external_auth_ldap(self):
api = UserApi(
current_user=None,
session=self.session,
config=self.app_config,
)
u = api.create_user(
email='[email protected]',
password=None,
name='bob',
auth_type=AuthType.LDAP,
timezone='+2',
lang='en',
do_save=True,
do_notify=False,
)
api._user = u
with pytest.raises(ExternalAuthUserPasswordModificationDisallowed):
api.set_password(
u,
'pass',
'pass',
'pass',
)