• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python backends.get_enabled_auth_backends函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reviewboard.accounts.backends.get_enabled_auth_backends函数的典型用法代码示例。如果您正苦于以下问题:Python get_enabled_auth_backends函数的具体用法?Python get_enabled_auth_backends怎么用?Python get_enabled_auth_backends使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_queryset

    def get_queryset(self, request, local_site_name=None, *args, **kwargs):
        search_q = request.GET.get('q', None)
        include_inactive = \
            request.GET.get('include-inactive', '0').lower() in ('1', 'true')

        for backend in get_enabled_auth_backends():
            try:
                backend.query_users(search_q, request)
            except Exception as e:
                logging.error('Error when calling query_users for auth '
                              'backend %r: %s',
                              backend, e, exc_info=1)

        local_site = self._get_local_site(local_site_name)
        is_list = kwargs.get('is_list', False)

        # When accessing individual users (not is_list) on public local sites,
        # we allow accessing any username. This is so that the links on reviews
        # and review requests from non-members won't be 404. The list is still
        # restricted to members of the site to avoid leaking information.
        if local_site and (is_list or not local_site.public):
            query = local_site.users.all()
        else:
            query = self.model.objects.all()

        if is_list and not include_inactive:
            query = query.filter(is_active=True)

        if search_q:
            q = None

            # Auth backends may have special naming conventions for users that
            # they'd like to be represented in search. If any auth backends
            # implement search_users, prefer that over the built-in searching.
            for backend in get_enabled_auth_backends():
                try:
                    q = backend.search_users(search_q, request)
                except Exception as e:
                    logging.error('Error when calling search_users for auth '
                                  'backend %r: %s',
                                  backend, e, exc_info=1)

                if q:
                    break

            if not q:
                q = Q(username__istartswith=search_q)

                if request.GET.get('fullname', None):
                    q = q | (Q(first_name__istartswith=search_q) |
                             Q(last_name__istartswith=search_q))

            query = query.filter(q)

        return query.extra(select={
            'is_private': ('SELECT is_private FROM accounts_profile '
                           'WHERE accounts_profile.user_id = auth_user.id')
        })
开发者ID:darmhoo,项目名称:reviewboard,代码行数:58,代码来源:user.py


示例2: clean_old_password

    def clean_old_password(self):
        backend = get_enabled_auth_backends()[0]

        password = self.cleaned_data['old_password']

        if not backend.authenticate(self.user.username, password):
            raise forms.ValidationError(_('This password is incorrect'))
开发者ID:dybs,项目名称:reviewboard,代码行数:7,代码来源:pages.py


示例3: get_queryset

    def get_queryset(self, request, local_site_name=None, *args, **kwargs):
        search_q = request.GET.get('q', None)

        for backend in get_enabled_auth_backends():
            backend.query_users(search_q, request)

        local_site = self._get_local_site(local_site_name)
        if local_site:
            query = local_site.users.filter(is_active=True)
        else:
            query = self.model.objects.filter(is_active=True)

        if search_q:
            q = Q(username__istartswith=search_q)

            if request.GET.get('fullname', None):
                q = q | (Q(first_name__istartswith=search_q) |
                         Q(last_name__istartswith=search_q))

            query = query.filter(q)

        return query.extra(select={
            'is_private': ('SELECT is_private FROM accounts_profile '
                           'WHERE accounts_profile.user_id = auth_user.id')
        })
开发者ID:javins,项目名称:reviewboard,代码行数:25,代码来源:user.py


示例4: save

    def save(self):
        """Save the form."""
        backend = get_enabled_auth_backends()[0]

        if backend.supports_change_name:
            self.user.first_name = self.cleaned_data['first_name']
            self.user.last_name = self.cleaned_data['last_name']

            try:
                backend.update_name(self.user)
            except Exception as e:
                logging.error('Error when calling update_name for auth '
                              'backend %r: %s',
                              backend, e, exc_info=1)

        if backend.supports_change_email:
            new_email = self.cleaned_data['email']

            if new_email != self.user.email:
                self.user.email = new_email

                try:
                    backend.update_email(self.user)
                except Exception as e:
                    logging.error('Error when calling update_email for auth '
                                  'backend %r: %s',
                                  backend, e, exc_info=1)

        self.user.save()

        self.profile.is_private = self.cleaned_data['profile_private']
        self.profile.save()

        messages.add_message(self.request, messages.INFO,
                             _('Your profile has been saved.'))
开发者ID:xiaogao6681,项目名称:reviewboard,代码行数:35,代码来源:pages.py


示例5: process_response

    def process_response(self, request, response):
        if BugzillaBackend not in [x.__class__ for
                                   x in get_enabled_auth_backends()]:
            return response

        if not request.user.is_authenticated():
            for key in ('Bugzilla_login', 'Bugzilla_logincookie'):
                try:
                    del request.session[key]
                except KeyError:
                    pass

            return response

        try:
            bzlogin = getattr(request.user, 'bzlogin')
            bzcookie = getattr(request.user, 'bzcookie')
        except AttributeError:
            return response

        if not bzlogin or not bzcookie:
            return response

        request.session['Bugzilla_login'] = bzlogin
        request.session['Bugzilla_logincookie'] = bzcookie
        return response
开发者ID:smacleod,项目名称:rbbz,代码行数:26,代码来源:middleware.py


示例6: process_request

    def process_request(self, request):
        if BugzillaBackend not in [x.__class__ for
                                   x in get_enabled_auth_backends()]:
            return

        request.user.bzlogin = request.session.get('Bugzilla_login')
        request.user.bzcookie = request.session.get('Bugzilla_logincookie')
开发者ID:smacleod,项目名称:rbbz,代码行数:7,代码来源:middleware.py


示例7: save

    def save(self):
        backend = get_enabled_auth_backends()[0]
        backend.update_password(self.user, self.cleaned_data['password1'])
        self.user.save()

        messages.add_message(self.request, messages.INFO,
                             _('Your password has been changed.'))
开发者ID:dybs,项目名称:reviewboard,代码行数:7,代码来源:pages.py


示例8: is_visible

    def is_visible(self):
        """Return whether or not the "change password" form should be shown.

        Returns:
            bool:
            Whether or not the form will be rendered.
        """
        return (super(ChangePasswordForm, self).is_visible() and
                get_enabled_auth_backends()[0].supports_change_password)
开发者ID:chipx86,项目名称:reviewboard,代码行数:9,代码来源:pages.py


示例9: _get_standard_auth_backend

    def _get_standard_auth_backend(self):
        backend = None

        for backend in get_enabled_auth_backends():
            # We do not use isinstance here because we specifically want a
            # StandardAuthBackend and not an instance of a subclass of it.
            if type(backend) is StandardAuthBackend:
                break

        self.assertIs(type(backend), StandardAuthBackend)

        return backend
开发者ID:xiaogao6681,项目名称:reviewboard,代码行数:12,代码来源:tests.py


示例10: get_queryset

    def get_queryset(self, request, local_site_name=None, *args, **kwargs):
        search_q = request.GET.get('q', None)

        for backend in get_enabled_auth_backends():
            backend.query_users(search_q, request)

        local_site = self._get_local_site(local_site_name)
        if local_site:
            query = local_site.users.filter(is_active=True)
        else:
            query = self.model.objects.filter(is_active=True)

        if search_q:
            q = None

            # Auth backends may have special naming conventions for users that
            # they'd like to be represented in search. If any auth backends
            # implement search_users, prefer that over the built-in searching.
            for backend in get_enabled_auth_backends():
                q = backend.search_users(search_q, request)

                if q:
                    break

            if not q:
                q = Q(username__istartswith=search_q)

                if request.GET.get('fullname', None):
                    q = q | (Q(first_name__istartswith=search_q) |
                             Q(last_name__istartswith=search_q))

            query = query.filter(q)

        return query.extra(select={
            'is_private': ('SELECT is_private FROM accounts_profile '
                           'WHERE accounts_profile.user_id = auth_user.id')
        })
开发者ID:iosphere,项目名称:reviewboard,代码行数:37,代码来源:user.py


示例11: load

    def load(self):
        self.set_initial({
            'first_name': self.user.first_name,
            'last_name': self.user.last_name,
            'email': self.user.email,
            'profile_private': self.profile.is_private,
        })

        backend = get_enabled_auth_backends()[0]

        if not backend.supports_change_name:
            del self.fields['first_name']
            del self.fields['last_name']

        if not backend.supports_change_email:
            del self.fields['email']
开发者ID:dybs,项目名称:reviewboard,代码行数:16,代码来源:pages.py


示例12: save

    def save(self):
        backend = get_enabled_auth_backends()[0]

        try:
            backend.update_password(self.user, self.cleaned_data['password1'])

            self.user.save()

            messages.add_message(self.request, messages.INFO,
                                 _('Your password has been changed.'))
        except Exception as e:
            logging.error('Error when calling update_password for auth '
                          'backend %r: %s',
                          backend, e, exc_info=1)
            messages.add_message(self.request, messages.INFO,
                                 _('Unexpected error when changing your '
                                   'password. Please contact the '
                                   'administrator.'))
开发者ID:iapilgrim,项目名称:reviewboard,代码行数:18,代码来源:pages.py


示例13: clean_old_password

    def clean_old_password(self):
        backend = get_enabled_auth_backends()[0]

        password = self.cleaned_data['old_password']

        try:
            is_authenticated = backend.authenticate(self.user.username,
                                                    password)
        except Exception as e:
            logging.error('Error when calling authenticate for auth backend '
                          '%r: %s',
                          backend, e, exc_info=1)
            raise forms.ValidationError(_('Unexpected error when validating '
                                          'the password. Please contact the '
                                          'administrator.'))

        if not is_authenticated:
            raise forms.ValidationError(_('This password is incorrect'))
开发者ID:iapilgrim,项目名称:reviewboard,代码行数:18,代码来源:pages.py


示例14: account_register

def account_register(request, next_url='dashboard'):
    """Display the appropriate registration page.

    If registration is enabled and the selected authentication backend supports
    creation of users, this will return the appropriate registration page. If
    registration is not supported, this will redirect to the login view.
    """
    siteconfig = SiteConfiguration.objects.get_current()
    auth_backends = get_enabled_auth_backends()

    if (auth_backends[0].supports_registration and
            siteconfig.get("auth_enable_registration")):
        response = register(request, next_page=reverse(next_url),
                            form_class=RegistrationForm)

        return response

    return HttpResponseRedirect(reverse("login"))
开发者ID:CharanKamal-CLI,项目名称:reviewboard,代码行数:18,代码来源:views.py


示例15: get_user_from_reviewer

def get_user_from_reviewer(request, reviewer):
    for backend in get_enabled_auth_backends():
        backend.query_users(reviewer, request)

    q = Q(username__icontains=reviewer)
    q = q | Q(is_active=True)

    users = User.objects.filter(q).all()
    # Try exact username match.
    for user in users:
        if user.username == reviewer:
            return user

    # Try case insensitive username match.
    for user in users:
        if user.username.lower() == reviewer.lower():
            return user

    return None
开发者ID:kilikkuo,项目名称:version-control-tools,代码行数:19,代码来源:batch_review_request.py


示例16: account_register

def account_register(request, next_url='dashboard'):
    """
    Handles redirection to the appropriate registration page, depending
    on the authentication type the user has configured.
    """
    siteconfig = SiteConfiguration.objects.get_current()
    auth_backends = get_enabled_auth_backends()

    if (auth_backends[0].supports_registration and
            siteconfig.get("auth_enable_registration")):
        response = register(request, next_page=reverse(next_url),
                            form_class=RegistrationForm)

        if request.user.is_authenticated():
            # This will trigger sending an e-mail notification for
            # user registration, if enabled.
            user_registered.send(sender=None, user=request.user)

        return response

    return HttpResponseRedirect(reverse("login"))
开发者ID:javins,项目名称:reviewboard,代码行数:21,代码来源:views.py


示例17: save

    def save(self):
        """Save the form."""
        from reviewboard.notifications.email.signal_handlers import \
            send_password_changed_mail

        backend = get_enabled_auth_backends()[0]

        try:
            backend.update_password(self.user, self.cleaned_data['password1'])

            self.user.save()

            messages.add_message(self.request, messages.INFO,
                                 _('Your password has been changed.'))
        except Exception as e:
            logging.error('Error when calling update_password for auth '
                          'backend %r: %s',
                          backend, e, exc_info=1)
            messages.add_message(self.request, messages.INFO,
                                 _('Unexpected error when changing your '
                                   'password. Please contact the '
                                   'administrator.'))
        else:
            send_password_changed_mail(self.user)
开发者ID:chipx86,项目名称:reviewboard,代码行数:24,代码来源:pages.py


示例18: _get_standard_auth_backend

    def _get_standard_auth_backend(self):
        # The StandardAuthBackend **SHOULD** be the last backend in the list.
        backend = get_enabled_auth_backends()[-1]
        self.assertIsInstance(backend, StandardAuthBackend)

        return backend
开发者ID:hanabishi,项目名称:reviewboard,代码行数:6,代码来源:tests.py


示例19: auth_backends

def auth_backends(request):
    """Add the enabled authentication backends to the template context."""
    return {
        'auth_backends': get_enabled_auth_backends(),
    }
开发者ID:CharanKamal-CLI,项目名称:reviewboard,代码行数:5,代码来源:context_processors.py


示例20: is_visible

    def is_visible(self):
        """Get whether or not the "change password" form should be shown."""
        backend = get_enabled_auth_backends()[0]

        return backend.supports_change_password
开发者ID:sgallagher,项目名称:reviewboard,代码行数:5,代码来源:pages.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pages.register_account_page_class函数代码示例发布时间:2022-05-26
下一篇:
Python reviewboard.is_release函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap