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


Python auth.get_auth_providers函数代码示例

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


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


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