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

Python auth.get_auth_providers函数代码示例

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

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



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

示例1: register

def register(request):
    from django.conf import settings

    if not (settings.SENTRY_ALLOW_REGISTRATION or request.session.get('can_register')):
        return HttpResponseRedirect(reverse('sentry'))

    form = RegistrationForm(request.POST or None,
                            captcha=bool(request.session.get('needs_captcha')))
    if form.is_valid():
        user = form.save()

        # can_register should only allow a single registration
        request.session.pop('can_register', None)

        # HACK: grab whatever the first backend is and assume it works
        user.backend = settings.AUTHENTICATION_BACKENDS[0]

        login_user(request, user)

        request.session.pop('needs_captcha', None)

        return login_redirect(request)

    elif request.POST and not request.session.get('needs_captcha'):
        request.session['needs_captcha'] = 1
        form = RegistrationForm(request.POST or None, captcha=True)
        form.errors.pop('captcha', None)

    return render_to_response('sentry/register.html', {
        'form': form,
        'AUTH_PROVIDERS': get_auth_providers(),
        'SOCIAL_AUTH_CREATE_USERS': settings.SOCIAL_AUTH_CREATE_USERS,
    }, request)
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:33,代码来源:accounts.py


示例2: handle

 def handle(self, request):
     return self.respond('sentry/account/security.html', {
         'page': 'security',
         'has_2fa': Authenticator.objects.user_has_2fa(request.user),
         'AUTH_PROVIDERS': get_auth_providers(),
         'has_newsletters': newsletter.is_enabled,
     })
开发者ID:duanshuaimin,项目名称:sentry,代码行数:7,代码来源:account_security.py


示例3: handle

    def handle(self, request):
        if request.user.is_authenticated():
            return self.redirect(get_login_redirect(request))

        form = AuthenticationForm(request, request.POST or None,
                                  captcha=bool(request.session.get('needs_captcha')))
        if form.is_valid():
            login(request, form.get_user())

            request.session.pop('needs_captcha', None)

            return self.redirect(get_login_redirect(request))

        elif request.POST and not request.session.get('needs_captcha'):
            request.session['needs_captcha'] = 1
            form = AuthenticationForm(request, request.POST or None, captcha=True)
            form.errors.pop('captcha', None)

        request.session.set_test_cookie()

        context = {
            'form': form,
            'next': request.session.get('_next'),
            'CAN_REGISTER': settings.SENTRY_ALLOW_REGISTRATION or request.session.get('can_register'),
            'AUTH_PROVIDERS': get_auth_providers(),
            'SOCIAL_AUTH_CREATE_USERS': settings.SOCIAL_AUTH_CREATE_USERS,
        }
        return self.respond('sentry/login.html', context)
开发者ID:BlueMoebius,项目名称:sentry,代码行数:28,代码来源:auth_login.py


示例4: settings

def settings(request):
    form = AccountSettingsForm(request.user, request.POST or None, initial={
        'email': request.user.email,
        'username': request.user.username,
        'name': request.user.name,
    })
    if form.is_valid():
        old_email = request.user.email
        user = form.save()
        if user.email != old_email:
            UserEmail.objects.get(user=request.user, email=old_email).delete()
            try:
                with transaction.atomic():
                    user_email = UserEmail.objects.create(user=user, email=user.email)
            except IntegrityError:
                pass
            else:
                user_email.set_hash()
                user_email.save()
            user.send_confirm_emails()
        messages.add_message(request, messages.SUCCESS, 'Your settings were saved.')
        return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update({
        'form': form,
        'page': 'settings',
        'has_2fa': Authenticator.objects.user_has_2fa(request.user),
        'AUTH_PROVIDERS': get_auth_providers(),
    })
    return render_to_response('sentry/account/settings.html', context, request)
开发者ID:Akashguharoy,项目名称:sentry,代码行数:31,代码来源:accounts.py


示例5: manage_subscriptions

def manage_subscriptions(request):
    user = request.user
    email = UserEmail.get_primary_email(user)

    if request.method == 'GET':
        context = csrf(request)
        context.update(
            {
                'page': 'subscriptions',
                'email': email,
                'AUTH_PROVIDERS': auth.get_auth_providers(),
                'has_newsletters': newsletter.is_enabled,
                'subscriptions': newsletter.get_subscriptions(user),
            }
        )
        return render_to_response('sentry/account/subscriptions.html', context, request)

    subscribed = request.POST.get('subscribed') == '1'
    try:
        list_id = int(request.POST.get('listId', ''))
    except ValueError:
        return HttpResponse('bad request', status=400)

    kwargs = {
        'list_id': list_id,
        'subscribed': subscribed,
        'verified': email.is_verified,
    }
    if not subscribed:
        kwargs['unsubscribed_date'] = timezone.now()
    else:
        kwargs['subscribed_date'] = timezone.now()

    newsletter.create_or_update_subscription(user, **kwargs)
    return HttpResponse()
开发者ID:hosmelq,项目名称:sentry,代码行数:35,代码来源:accounts.py


示例6: login

def login(request):
    from django.contrib.auth import login as login_
    from django.contrib.auth.forms import AuthenticationForm

    if request.user.is_authenticated():
        return login_redirect(request)

    form = AuthenticationForm(request, request.POST or None)
    if form.is_valid():
        login_(request, form.get_user())
        return login_redirect(request)
    else:
        request.session.set_test_cookie()

    AUTH_PROVIDERS = get_auth_providers()

    context = csrf(request)
    context.update(
        {
            "form": form,
            "next": request.session.get("_next"),
            "AUTH_PROVIDERS": AUTH_PROVIDERS,
            "SOCIAL_AUTH_CREATE_USERS": dj_settings.SOCIAL_AUTH_CREATE_USERS,
        }
    )
    return render_to_response("sentry/login.html", context, request)
开发者ID:Crowdbooster,项目名称:sentry,代码行数:26,代码来源:accounts.py


示例7: appearance_settings

def appearance_settings(request):
    from django.conf import settings

    options = UserOption.objects.get_all_values(user=request.user, project=None)

    form = AppearanceSettingsForm(
        request.user,
        request.POST or None,
        initial={
            'language': options.get('language') or request.LANGUAGE_CODE,
            'stacktrace_order': int(options.get('stacktrace_order', -1) or -1),
            'timezone': options.get('timezone') or settings.SENTRY_DEFAULT_TIME_ZONE,
            'clock_24_hours': options.get('clock_24_hours') or False,
        }
    )
    if form.is_valid():
        form.save()
        messages.add_message(request, messages.SUCCESS, 'Your settings were saved.')
        return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update(
        {
            'form': form,
            'page': 'appearance',
            'AUTH_PROVIDERS': auth.get_auth_providers(),
            'has_newsletters': newsletter.is_enabled,
        }
    )
    return render_to_response('sentry/account/appearance.html', context, request)
开发者ID:hosmelq,项目名称:sentry,代码行数:30,代码来源:accounts.py


示例8: avatar_settings

def avatar_settings(request):
    context = csrf(request)
    context.update({
        'page': 'avatar',
        'AUTH_PROVIDERS': get_auth_providers(),
    })
    return render_to_response('sentry/account/avatar.html', context, request)
开发者ID:Akashguharoy,项目名称:sentry,代码行数:7,代码来源:accounts.py


示例9: handle

    def handle(self, request):
        if request.user.is_authenticated():
            return self.redirect(get_login_redirect(request))

        form = AuthenticationForm(request, request.POST or None, captcha=bool(request.session.get("needs_captcha")))
        if form.is_valid():
            login(request, form.get_user())

            request.session.pop("needs_captcha", None)

            return self.redirect(get_login_redirect(request))

        elif request.POST and not request.session.get("needs_captcha"):
            request.session["needs_captcha"] = 1
            form = AuthenticationForm(request, request.POST or None, captcha=True)
            form.errors.pop("captcha", None)

        request.session.set_test_cookie()

        context = {
            "form": form,
            "next": request.session.get("_next"),
            "CAN_REGISTER": features.has("auth:register") or request.session.get("can_register"),
            "AUTH_PROVIDERS": get_auth_providers(),
            "SOCIAL_AUTH_CREATE_USERS": features.has("social-auth:register"),
        }
        return self.respond("sentry/login.html", context)
开发者ID:Juraldinio,项目名称:sentry,代码行数:27,代码来源:auth_login.py


示例10: login

def login(request):
    from django.conf import settings

    if request.user.is_authenticated():
        return login_redirect(request)

    form = AuthenticationForm(request, request.POST or None,
                              captcha=bool(request.session.get('needs_captcha')))
    if form.is_valid():
        login_user(request, form.get_user())

        request.session.pop('needs_captcha', None)

        return login_redirect(request)

    elif request.POST and not request.session.get('needs_captcha'):
        request.session['needs_captcha'] = 1
        form = AuthenticationForm(request, request.POST or None, captcha=True)
        form.errors.pop('captcha', None)

    request.session.set_test_cookie()

    context = csrf(request)
    context.update({
        'form': form,
        'next': request.session.get('_next'),
        'CAN_REGISTER': settings.SENTRY_ALLOW_REGISTRATION or request.session.get('can_register'),
        'AUTH_PROVIDERS': get_auth_providers(),
        'SOCIAL_AUTH_CREATE_USERS': settings.SOCIAL_AUTH_CREATE_USERS,
    })
    return render_to_response('sentry/login.html', context, request)
开发者ID:DNIWE-Systems,项目名称:sentry,代码行数:31,代码来源:accounts.py


示例11: register

def register(request):
    from sentry.conf import settings

    if not (settings.ALLOW_REGISTRATION or request.session.get("can_register")):
        return HttpResponseRedirect(reverse("sentry"))

    form = RegistrationForm(request.POST or None)
    if form.is_valid():
        user = form.save()

        # can_register should only allow a single registration
        request.session.pop("can_register", None)

        # HACK: grab whatever the first backend is and assume it works
        user.backend = dj_settings.AUTHENTICATION_BACKENDS[0]

        login_user(request, user)

        return login_redirect(request)

    return render_to_response(
        "sentry/register.html",
        {
            "form": form,
            "AUTH_PROVIDERS": get_auth_providers(),
            "SOCIAL_AUTH_CREATE_USERS": dj_settings.SOCIAL_AUTH_CREATE_USERS,
        },
        request,
    )
开发者ID:acdha,项目名称:sentry,代码行数:29,代码来源:accounts.py


示例12: login

def login(request):
    from django.contrib.auth.forms import AuthenticationForm
    from sentry.conf import settings

    if request.user.is_authenticated():
        return login_redirect(request)

    form = AuthenticationForm(request, request.POST or None)
    if form.is_valid():
        login_user(request, form.get_user())
        return login_redirect(request)

    request.session.set_test_cookie()

    context = csrf(request)
    context.update(
        {
            "form": form,
            "next": request.session.get("_next"),
            "CAN_REGISTER": settings.ALLOW_REGISTRATION or request.session.get("can_register"),
            "AUTH_PROVIDERS": get_auth_providers(),
            "SOCIAL_AUTH_CREATE_USERS": dj_settings.SOCIAL_AUTH_CREATE_USERS,
        }
    )
    return render_to_response("sentry/login.html", context, request)
开发者ID:acdha,项目名称:sentry,代码行数:25,代码来源:accounts.py


示例13: notification_settings

def notification_settings(request):
    settings_form = NotificationSettingsForm(request.user, request.POST or None)

    # TODO(dcramer): this is an extremely bad pattern and we need a more optimal
    # solution for rendering this (that ideally plays well with the org data)
    project_list = []
    organization_list = Organization.objects.get_for_user(
        user=request.user,
    )
    for organization in organization_list:
        team_list = Team.objects.get_for_user(
            user=request.user,
            organization=organization,
        )
        for team in team_list:
            project_list.extend(
                Project.objects.get_for_user(
                    user=request.user,
                    team=team,
                )
            )

    project_forms = [
        (project, ProjectEmailOptionsForm(
            project, request.user,
            request.POST or None,
            prefix='project-%s' % (project.id,)
        ))
        for project in sorted(project_list, key=lambda x: (
            x.team.name if x.team else None, x.name))
    ]

    ext_forms = []
    for plugin in plugins.all():
        for form in safe_execute(plugin.get_notification_forms) or ():
            form = safe_execute(form, plugin, request.user, request.POST or None, prefix=plugin.slug)
            if not form:
                continue
            ext_forms.append(form)

    if request.POST:
        all_forms = list(itertools.chain(
            [settings_form], ext_forms, (f for _, f in project_forms)
        ))
        if all(f.is_valid() for f in all_forms):
            for form in all_forms:
                form.save()
            messages.add_message(request, messages.SUCCESS, 'Your settings were saved.')
            return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update({
        'settings_form': settings_form,
        'project_forms': project_forms,
        'ext_forms': ext_forms,
        'page': 'notifications',
        'AUTH_PROVIDERS': get_auth_providers(),
    })
    return render_to_response('sentry/account/notifications.html', context, request)
开发者ID:AyrtonRicardo,项目名称:sentry,代码行数:59,代码来源:accounts.py


示例14: avatar_settings

def avatar_settings(request):
    context = csrf(request)
    context.update({
        'page': 'avatar',
        'AUTH_PROVIDERS': auth.get_auth_providers(),
        'has_newsletters': newsletter.is_enabled,
    })
    return render_to_response('sentry/account/avatar.html', context, request)
开发者ID:sashahilton00,项目名称:sentry,代码行数:8,代码来源:accounts.py


示例15: list_identities

def list_identities(request):
    from social_auth.models import UserSocialAuth

    identity_list = list(UserSocialAuth.objects.filter(user=request.user))

    AUTH_PROVIDERS = get_auth_providers()

    context = csrf(request)
    context.update({"identity_list": identity_list, "page": "identities", "AUTH_PROVIDERS": AUTH_PROVIDERS})
    return render_to_response("sentry/account/identities.html", context, request)
开发者ID:acdha,项目名称:sentry,代码行数:10,代码来源:accounts.py


示例16: account_settings

def account_settings(request):
    user = request.user

    form = AccountSettingsForm(
        user, request, request.POST or None,
        initial={
            'email': UserEmail.get_primary_email(user).email,
            'username': user.username,
            'name': user.name,
        },
    )

    if form.is_valid():
        old_email = user.email

        form.save()

        # remove previously valid email address
        # TODO(dcramer): we should maintain validation here when we support
        # multiple email addresses
        if request.user.email != old_email:
            UserEmail.objects.filter(user=user, email=old_email).delete()
            try:
                with transaction.atomic():
                    user_email = UserEmail.objects.create(
                        user=user,
                        email=user.email,
                    )
            except IntegrityError:
                pass
            else:
                user_email.set_hash()
                user_email.save()
                user.send_confirm_email_singular(user_email)
                msg = _('A confirmation email has been sent to %s.') % user_email.email
                messages.add_message(
                    request,
                    messages.SUCCESS,
                    msg)

        messages.add_message(
            request, messages.SUCCESS, _('Your settings were saved.'))
        return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update({
        'form': form,
        'page': 'settings',
        'has_2fa': Authenticator.objects.user_has_2fa(request.user),
        'AUTH_PROVIDERS': auth.get_auth_providers(),
        'email': UserEmail.get_primary_email(user),
        'has_newsletters': newsletter.is_enabled,
    })
    return render_to_response('sentry/account/settings.html', context, request)
开发者ID:faulkner,项目名称:sentry,代码行数:54,代码来源:accounts.py


示例17: handle

    def handle(self, request):
        settings_form = self.notification_settings_form(
            request.user, request.POST or None)
        reports_form = NotificationReportSettingsForm(
            request.user, request.POST or None,
            prefix='reports')

        project_list = list(Project.objects.filter(
            team__organizationmemberteam__organizationmember__user=request.user,
            team__organizationmemberteam__is_active=True,
            status=ProjectStatus.VISIBLE,
        ).distinct())

        project_forms = [
            (project, ProjectEmailOptionsForm(
                project, request.user,
                request.POST or None,
                prefix='project-%s' % (project.id,)
            ))
            for project in sorted(project_list, key=lambda x: (
                x.organization.name, x.name))
        ]

        ext_forms = []
        for plugin in plugins.all():
            for form in safe_execute(plugin.get_notification_forms, _with_transaction=False) or ():
                form = safe_execute(form, plugin, request.user, request.POST or None, prefix=plugin.slug,
                                    _with_transaction=False)
                if not form:
                    continue
                ext_forms.append(form)

        if request.POST:
            all_forms = list(itertools.chain(
                [settings_form, reports_form],
                ext_forms,
                (f for _, f in project_forms)
            ))
            if all(f.is_valid() for f in all_forms):
                for form in all_forms:
                    form.save()
                messages.add_message(request, messages.SUCCESS, 'Your settings were saved.')
                return HttpResponseRedirect(request.path)

        context = csrf(request)
        context.update({
            'settings_form': settings_form,
            'project_forms': project_forms,
            'reports_form': reports_form,
            'ext_forms': ext_forms,
            'page': 'notifications',
            'AUTH_PROVIDERS': get_auth_providers(),
        })
        return render_to_response('sentry/account/notifications.html', context, request)
开发者ID:bsergean,项目名称:sentry,代码行数:54,代码来源:account_notification.py


示例18: list_identities

def list_identities(request):
    identity_list = list(UserSocialAuth.objects.filter(user=request.user))

    AUTH_PROVIDERS = auth.get_auth_providers()

    context = csrf(request)
    context.update({
        'identity_list': identity_list,
        'page': 'identities',
        'AUTH_PROVIDERS': AUTH_PROVIDERS,
    })
    return render_to_response('sentry/account/identities.html', context, request)
开发者ID:ollie314,项目名称:sentry,代码行数:12,代码来源:accounts.py


示例19: settings

def settings(request):
    form = AccountSettingsForm(request.user, request.POST or None, initial={
        'email': request.user.email,
        'username': request.user.username,
        'name': request.user.name,
    })
    if form.is_valid():
        form.save()
        messages.add_message(request, messages.SUCCESS, 'Your settings were saved.')
        return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update({
        'form': form,
        'page': 'settings',
        'AUTH_PROVIDERS': get_auth_providers(),
    })
    return render_to_response('sentry/account/settings.html', context, request)
开发者ID:280185386,项目名称:sentry,代码行数:18,代码来源:accounts.py


示例20: notification_settings

def notification_settings(request):
    settings_form = NotificationSettingsForm(request.user, request.POST or None)

    project_list = Project.objects.get_for_user(request.user, access=MEMBER_USER)
    project_forms = [
        (project, ProjectEmailOptionsForm(
            project, request.user,
            request.POST or None,
            prefix='project-%s' % (project.id,)
        ))
        for project in sorted(project_list, key=lambda x: (x.team.name, x.name))
    ]

    ext_forms = []
    for plugin in plugins.all():
        for form in safe_execute(plugin.get_notification_forms) or ():
            form = safe_execute(form, plugin, request.user, request.POST or None, prefix=plugin.slug)
            if not form:
                continue
            ext_forms.append(form)

    if request.POST:
        all_forms = list(itertools.chain(
            [settings_form], ext_forms, (f for _, f in project_forms)
        ))
        if all(f.is_valid() for f in all_forms):
            for form in all_forms:
                form.save()
            messages.add_message(request, messages.SUCCESS, 'Your settings were saved.')
            return HttpResponseRedirect(request.path)

    context = csrf(request)
    context.update({
        'settings_form': settings_form,
        'project_forms': project_forms,
        'ext_forms': ext_forms,
        'page': 'notifications',
        'AUTH_PROVIDERS': get_auth_providers(),
    })
    return render_to_response('sentry/account/notifications.html', context, request)
开发者ID:aai,项目名称:sentry,代码行数:40,代码来源:accounts.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python auth.get_login_redirect函数代码示例发布时间:2022-05-27
下一篇:
Python auth.find_users函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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