本文整理汇总了Python中tracim_backend.lib.core.user.UserApi.reset_password_notification方法的典型用法代码示例。如果您正苦于以下问题:Python UserApi.reset_password_notification方法的具体用法?Python UserApi.reset_password_notification怎么用?Python UserApi.reset_password_notification使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tracim_backend.lib.core.user.UserApi
的用法示例。
在下文中一共展示了UserApi.reset_password_notification方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_func__reset_password__ok__nominal_case
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import reset_password_notification [as 别名]
def test_func__reset_password__ok__nominal_case(self):
uapi = UserApi(
current_user=None,
session=self.session,
config=self.app_config,
)
current_user = uapi.get_one_by_email('[email protected]')
uapi.reset_password_notification(current_user, do_save=True)
transaction.commit()
# Send mail async from redis queue
redis = get_redis_connection(
self.app_config
)
queue = get_rq_queue(
redis,
'mail_sender',
)
worker = SimpleWorker([queue], connection=queue.connection)
worker.work(burst=True)
# check mail received
response = self.get_mailhog_mails()
headers = response[0]['Content']['Headers']
assert headers['From'][0] == 'Tracim Notifications <[email protected]>' # nopep8
assert headers['To'][0] == 'Global manager <ad[email protected]>'
assert headers['Subject'][0] == '[TRACIM] A password reset has been requested'
示例2: reset_password_request
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import reset_password_notification [as 别名]
def reset_password_request(self, context, request: TracimRequest, hapic_data=None): # nopep8
"""
Send a request to reset password. This will result in a new email sent to the user
with a token to be used for password reset operation.
"""
app_config = request.registry.settings['CFG']
uapi = UserApi(
None,
session=request.dbsession,
config=app_config,
)
user = uapi.get_one_by_email(hapic_data.body.email)
uapi.reset_password_notification(user, do_save=True)
return
示例3: test_api__reset_password_reset__err_400__password_does_not_match
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import reset_password_notification [as 别名]
def test_api__reset_password_reset__err_400__password_does_not_match(self):
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one()
uapi = UserApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
reset_password_token = uapi.reset_password_notification(admin, do_save=True) # nopep8
transaction.commit()
params = {
'email': '[email protected]',
'reset_password_token': reset_password_token,
'new_password': 'mynewpassword',
'new_password2': 'anotherpassword',
}
res = self.testapp.post_json(
'/api/v2/auth/password/reset/modify',
status=400,
params=params,
)
assert isinstance(res.json, dict)
assert 'code' in res.json.keys()
assert res.json_body['code'] == error.PASSWORD_DO_NOT_MATCH
示例4: test_api__reset_password_reset__err_400__expired_token
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import reset_password_notification [as 别名]
def test_api__reset_password_reset__err_400__expired_token(self):
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one()
uapi = UserApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
with freeze_time("1999-12-31 23:59:59"):
reset_password_token = uapi.reset_password_notification(
admin,
do_save=True
)
params = {
'email': '[email protected]',
'reset_password_token': reset_password_token,
'new_password': 'mynewpassword',
'new_password2': 'mynewpassword',
}
transaction.commit()
with freeze_time("2000-01-01 00:00:05"):
res = self.testapp.post_json(
'/api/v2/auth/password/reset/modify',
status=400,
params=params,
)
assert isinstance(res.json, dict)
assert 'code' in res.json.keys()
assert res.json_body['code'] == error.EXPIRED_RESET_PASSWORD_TOKEN # nopep8
示例5: test_api__reset_password_reset__ok_204__nominal_case
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import reset_password_notification [as 别名]
def test_api__reset_password_reset__ok_204__nominal_case(self):
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one()
uapi = UserApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
reset_password_token = uapi.reset_password_notification(admin, do_save=True) # nopep8
transaction.commit()
params = {
'email': '[email protected]',
'reset_password_token': reset_password_token,
'new_password': 'mynewpassword',
'new_password2': 'mynewpassword',
}
self.testapp.post_json(
'/api/v2/auth/password/reset/modify',
status=204,
params=params,
)
# check if password is correctly setted
self.testapp.authorization = (
'Basic',
(
'[email protected]',
'mynewpassword'
)
)
self.testapp.get(
'/api/v2/auth/whoami',
status=200,
)
示例6: test_api__reset_password_check_token__ok_204__unknown_auth
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import reset_password_notification [as 别名]
def test_api__reset_password_check_token__ok_204__unknown_auth(self):
# create new user without auth (default is unknown)
self.testapp.authorization = (
'Basic',
(
'[email protected]',
'[email protected]'
)
)
params = {
'email': '[email protected]',
'password': 'mysuperpassword',
'profile': 'users',
'timezone': 'Europe/Paris',
'lang': 'fr',
'public_name': 'test user',
'email_notification': False,
}
res = self.testapp.post_json(
'/api/v2/users',
status=200,
params=params,
)
res = res.json_body
assert res['user_id']
user_id = res['user_id']
# make a check of token
self.testapp.authorization = None
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one()
uapi = UserApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
user = uapi.get_one_by_email('[email protected]')
reset_password_token = uapi.reset_password_notification(user, do_save=True) # nopep8
transaction.commit()
params = {
'email': '[email protected]',
'reset_password_token': reset_password_token
}
self.testapp.post_json(
'/api/v2/auth/password/reset/token/check',
status=204,
params=params,
)
示例7: test_api__reset_password_check_token__ok_204__nominal_case
# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import reset_password_notification [as 别名]
def test_api__reset_password_check_token__ok_204__nominal_case(self):
dbsession = get_tm_session(self.session_factory, transaction.manager)
admin = dbsession.query(User) \
.filter(User.email == '[email protected]') \
.one()
uapi = UserApi(
current_user=admin,
session=dbsession,
config=self.app_config,
)
reset_password_token = uapi.reset_password_notification(admin, do_save=True) # nopep8
transaction.commit()
params = {
'email': '[email protected]',
'reset_password_token': reset_password_token
}
self.testapp.post_json(
'/api/v2/auth/password/reset/token/check',
status=204,
params=params,
)