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


Python UserApi.get_one_by_email方法代码示例

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


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

示例1: test_unit__get_one_by_email__err__user_does_not_exist

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
 def test_unit__get_one_by_email__err__user_does_not_exist(self):
     api = UserApi(
         current_user=None,
         session=self.session,
         config=self.app_config,
     )
     with pytest.raises(UserDoesNotExist):
         api.get_one_by_email('unknown')
开发者ID:tracim,项目名称:tracim,代码行数:10,代码来源:test_user_api.py

示例2: test_func__create_new_content_with_notification__ok__nominal_case

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
    def test_func__create_new_content_with_notification__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]')
        # Create new user with notification enabled on w1 workspace
        wapi = WorkspaceApi(
            current_user=current_user,
            session=self.session,
            config=self.app_config,
        )
        workspace = wapi.get_one_by_label('Recipes')
        user = uapi.get_one_by_email('[email protected]')
        wapi.enable_notifications(user, workspace)

        api = ContentApi(
            current_user=user,
            session=self.session,
            config=self.app_config,
        )
        item = api.create(
            content_type_list.Folder.slug,
            workspace,
            None,
            'parent',
            do_save=True,
            do_notify=False,
        )
        item2 = api.create(
            content_type_list.File.slug,
            workspace,
            item,
            'file1',
            do_save=True,
            do_notify=True,
        )
        # 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] == '"Bob i. via Tracim" <[email protected]>'  # nopep8
        assert headers['To'][0] == 'Global manager <[email protected]>'
        assert headers['Subject'][0] == '[TRACIM] [Recipes] file1 (Open)'
        assert headers['References'][0] == '[email protected]'
        assert headers['Reply-to'][0] == '"Bob i. & all members of Recipes" <[email protected]>'  # nopep8
开发者ID:tracim,项目名称:tracim,代码行数:58,代码来源:test_mail_notification.py

示例3: isRealmUser

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
 def isRealmUser(self, realmname: str, username: str, environ: typing.Dict[str, typing.Any]) -> bool:
     """
     Called to check if for a given root, the username exists (though here we don't make difference between
     root as we're always starting at tracim's root
     """
     session = environ['tracim_dbsession'] # type: Session
     api = UserApi(None, session, self.app_config)
     try:
          api.get_one_by_email(username)
          return True
     except:
          return False
开发者ID:tracim,项目名称:tracim,代码行数:14,代码来源:authentification.py

示例4: test_func__create_comment_with_notification__ok__nominal_case

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
    def test_func__create_comment_with_notification__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]')
        # set admin as french, useful to verify if i18n work properly
        current_user.lang = 'fr'
        # Create new user with notification enabled on w1 workspace
        wapi = WorkspaceApi(
            current_user=current_user,
            session=self.session,
            config=self.app_config,
        )
        workspace = wapi.get_one_by_label('Recipes')
        user = uapi.get_one_by_email('[email protected]')
        wapi.enable_notifications(user, workspace)

        api = ContentApi(
            current_user=user,
            session=self.session,
            config=self.app_config,
        )
        item = api.create(
            content_type_list.Folder.slug,
            workspace,
            None,
            'parent',
            do_save=True,
            do_notify=False,
        )
        item2 = api.create(
            content_type_list.File.slug,
            workspace,
            item,
            'file1',
            do_save=True,
            do_notify=False,
        )
        api.create_comment(parent=item2, content='My super comment', do_save=True, do_notify=True)
        transaction.commit()

        # check mail received
        response = self.get_mailhog_mails()
        headers = response[0]['Content']['Headers']
        assert headers['From'][0] == '"Bob i. via Tracim" <[email protected]>'  # nopep8
        assert headers['To'][0] == 'Global manager <[email protected]>'
        assert headers['Subject'][0] == '[TRACIM] [Recipes] file1 (Open)'
        assert headers['References'][0] == '[email protected]'
        assert headers['Reply-to'][0] == '"Bob i. & all members of Recipes" <[email protected]>'  # nopep8
开发者ID:tracim,项目名称:tracim,代码行数:53,代码来源:test_mail_notification.py

示例5: test_func__reset_password__ok__nominal_case

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [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 <[email protected]>'
     assert headers['Subject'][0] == '[TRACIM] A password reset has been requested'
开发者ID:tracim,项目名称:tracim,代码行数:27,代码来源:test_mail_notification.py

示例6: _get_user

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
 def _get_user(self, user_email: typing.Callable):
     user_email = user_email()
     uapi = UserApi(
         None,
         show_deleted=True,
         session=self.dbsession,
         config=self.app_config
     )
     return uapi.get_one_by_email(user_email)
开发者ID:tracim,项目名称:tracim,代码行数:11,代码来源:dav_provider.py

示例7: test_unit__create_minimal_user_and_update__ok__nominal_case

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
 def test_unit__create_minimal_user_and_update__ok__nominal_case(self):
     api = UserApi(
         current_user=None,
         session=self.session,
         config=self.app_config,
     )
     u = api.create_minimal_user('[email protected]')
     api.update(u, 'bob', '[email protected]', 'password', do_save=True)
     nu = api.get_one_by_email('[email protected]')
     assert nu is not None
     assert nu.email == '[email protected]'
     assert nu.display_name == 'bob'
     assert nu.validate_password('password')
开发者ID:tracim,项目名称:tracim,代码行数:15,代码来源:test_user_api.py

示例8: test_get_one_by_email

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
    def test_get_one_by_email(self):
        api = UserApi(
            current_user=None,
            session=self.session,
            config=self.app_config,
        )
        u = api.create_minimal_user('[email protected]')
        self.session.flush()
        api.update(u, 'bibi', '[email protected]', 'password', do_save=True)
        uid = u.user_id
        transaction.commit()

        eq_(uid, api.get_one_by_email('[email protected]').user_id)
开发者ID:tracim,项目名称:tracim,代码行数:15,代码来源:test_user_api.py

示例9: 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 get_one_by_email [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

示例10: reset_password_check_token

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
 def reset_password_check_token(self, context, request: TracimRequest, hapic_data=None):   # nopep8
     """
     Check reset_password token. The token sent by email has a limited life duration,
     this API allow to check that the token is existing and still valid.
     """
     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.validate_reset_password_token(user, hapic_data.body.reset_password_token)  # nopep8
     return
开发者ID:tracim,项目名称:tracim,代码行数:16,代码来源:reset_password_controller.py

示例11: reset_password_request

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [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

示例12: reset_password_modify

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]
 def reset_password_modify(self, context, request: TracimRequest, hapic_data=None):   # nopep8
     """
     Do change the password. This requires the token received by email.
     After this request returns a 200, the user password is effectively changed
     """
     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.set_password_reset_token(
         new_password=hapic_data.body.new_password,
         new_password2=hapic_data.body.new_password2,
         reset_token=hapic_data.body.reset_password_token,
         user=user,
         do_save=True
     )
     return
开发者ID:tracim,项目名称:tracim,代码行数:22,代码来源:reset_password_controller.py

示例13: UserCommand

# 需要导入模块: from tracim_backend.lib.core.user import UserApi [as 别名]
# 或者: from tracim_backend.lib.core.user.UserApi import get_one_by_email [as 别名]

#.........这里部分代码省略.........
            password: str,
            do_notify: bool,
            **kwargs
    ) -> User:
        if not password:
            if self._password_required():
                raise BadCommandError(
                    "You must provide -p/--password parameter"
                )
            password = ''
        if self._user_api.check_email_already_in_db(login):
            raise UserAlreadyExistError()
        try:
            user = self._user_api.create_user(
                email=login,
                password=password,
                do_save=True,
                do_notify=do_notify,
            )
            # TODO - G.M - 04-04-2018 - [Caldav] Check this code
            # # We need to enable radicale if it not already done
            # daemons = DaemonsManager()
            # daemons.run('radicale', RadicaleDaemon)
            self._user_api.execute_created_user_actions(user)
        except IntegrityError as exception:
            self._session.rollback()
            raise UserAlreadyExistError() from exception
        except (NotificationSendingFailed, NotificationDisabledCantCreateUserWithInvitation) as exception:
            self._session.rollback()
            raise exception from exception
        return user

    def _update_password_for_login(self, login: str, password: str) -> None:
        user = self._user_api.get_one_by_email(login)
        self._user_api._check_password_modification_allowed(user)
        user.password = password
        self._session.flush()
        transaction.commit()

    def take_app_action(
            self,
            parsed_args: argparse.Namespace,
            app_context: AppEnvironment
    ) -> None:
        # TODO - G.M - 05-04-2018 -Refactor this in order
        # to not setup object var outside of __init__ .
        self._session = app_context['request'].dbsession
        self._app_config = app_context['registry'].settings['CFG']
        self._user_api = UserApi(
            current_user=None,
            session=self._session,
            config=self._app_config,
        )
        self._group_api = GroupApi(
            current_user=None,
            session=self._session,
            config=self._app_config,
        )
        user = self._proceed_user(parsed_args)
        self._proceed_groups(user, parsed_args)

        print("User created/updated")

    def _proceed_user(self, parsed_args: argparse.Namespace) -> User:
        self._check_context(parsed_args)
开发者ID:tracim,项目名称:tracim,代码行数:69,代码来源:user.py


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