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


Python UserApi.reset_password_notification方法代码示例

本文整理汇总了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'
开发者ID:tracim,项目名称:tracim,代码行数:27,代码来源:test_mail_notification.py

示例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
开发者ID:tracim,项目名称:tracim,代码行数:16,代码来源:reset_password_controller.py

示例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
开发者ID:tracim,项目名称:tracim,代码行数:28,代码来源:test_reset_password.py

示例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
开发者ID:tracim,项目名称:tracim,代码行数:33,代码来源:test_reset_password.py

示例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,
     )
开发者ID:tracim,项目名称:tracim,代码行数:37,代码来源:test_reset_password.py

示例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,
        )
开发者ID:tracim,项目名称:tracim,代码行数:52,代码来源:test_reset_password.py

示例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,
     )
开发者ID:tracim,项目名称:tracim,代码行数:23,代码来源:test_reset_password.py


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