Пример #1
0
def get_login_context(request, force_show_providers=False):
    slug = request.matchdict.get('discussion_slug', None)
    if slug:
        request.session['discussion'] = slug
    else:
        request.session.pop('discussion')
    discussion = discussion_from_request(request)
    get_routes = create_get_route(request, discussion)
    providers = get_provider_data(get_routes)
    hide_registration = (discussion
        and not public_roles.intersection(set(roles_with_permissions(
            discussion, P_READ)))
        and not roles_with_permissions(
            discussion, P_SELF_REGISTER_REQUEST, P_SELF_REGISTER))
    if not force_show_providers:
        hide_providers = aslist(request.registry.settings.get(
            'hide_login_providers', ()))

        if isinstance(hide_providers, (str, unicode)):
            hide_providers = (hide_providers, )
        providers = [p for p in providers if p['type'] not in hide_providers]

    return dict(get_default_context(request),
                providers=providers,
                providers_json=json.dumps(providers),
                saml_providers=request.registry.settings.get(
                    'SOCIAL_AUTH_SAML_ENABLED_IDPS', {}),
                hide_registration=hide_registration,
                identifier = request.params.get('identifier', ''),
                google_consumer_key=request.registry.settings.get(
                    'google.consumer_key', ''),
                next=handle_next_view(request),
                get_route=get_routes)
Пример #2
0
def get_login_context(request, force_show_providers=False):
    slug = request.matchdict.get('discussion_slug', None)
    if slug:
        p_slug = "/" + slug
        request.session['discussion'] = slug
    else:
        p_slug = ""
        request.session.pop('discussion')
    providers = get_providers_with_names()
    discussion = discussion_from_request(request)
    hide_registration = (discussion
        and not public_roles.intersection(set(roles_with_permissions(
            discussion, P_READ)))
        and not roles_with_permissions(
            discussion, P_SELF_REGISTER_REQUEST, P_SELF_REGISTER))
    if not force_show_providers:
        hide_providers = request.registry.settings.get(
            'hide_login_providers', ())

        if isinstance(hide_providers, (str, unicode)):
            hide_providers = (hide_providers, )
        for provider in hide_providers:
            del providers[provider]

    return dict(get_default_context(request),
                slug_prefix=p_slug,
                providers=providers,
                saml_providers=request.registry.settings.get(
                    'SOCIAL_AUTH_SAML_ENABLED_IDPS', {}),
                hide_registration=hide_registration,
                identifier = request.params.get('identifier', ''),
                google_consumer_key=request.registry.settings.get(
                    'google.consumer_key', ''),
                next=handle_next_view(request))
Пример #3
0
def get_login_context(request, force_show_providers=False):
    slug = request.matchdict.get('discussion_slug', None)
    if slug:
        p_slug = "/" + slug
        request.session['discussion'] = slug
    else:
        p_slug = ""
        request.session.pop('discussion')
    providers = get_providers_with_names()
    discussion = discussion_from_request(request)
    hide_registration = (discussion
        and not public_roles.intersection(set(roles_with_permissions(
            discussion, P_READ)))
        and not roles_with_permissions(
            discussion, P_SELF_REGISTER_REQUEST, P_SELF_REGISTER))
    if not force_show_providers:
        hide_providers = request.registry.settings.get(
            'hide_login_providers', ())

        if isinstance(hide_providers, (str, unicode)):
            hide_providers = (hide_providers, )
        for provider in hide_providers:
            del providers[provider]

    return dict(get_default_context(request),
                slug_prefix=p_slug,
                providers=providers,
                hide_registration=hide_registration,
                identifier = request.params.get('identifier', ''),
                google_consumer_key=request.registry.settings.get(
                    'google.consumer_key', ''),
                next=handle_next_view(request))
Пример #4
0
def get_login_context(request, force_show_providers=False):
    slug = request.matchdict.get('discussion_slug', None)
    if slug:
        request.session['discussion'] = slug
    else:
        request.session.pop('discussion')
    discussion = discussion_from_request(request)
    get_routes = create_get_route(request, discussion)
    providers = get_provider_data(get_routes)
    hide_registration = (discussion
        and not public_roles.intersection(set(roles_with_permissions(
            discussion, P_READ)))
        and not roles_with_permissions(
            discussion, P_SELF_REGISTER_REQUEST, P_SELF_REGISTER))
    if not force_show_providers:
        hide_providers = aslist(request.registry.settings.get(
            'hide_login_providers', ()))

        if isinstance(hide_providers, (str, unicode)):
            hide_providers = (hide_providers, )
        providers = [p for p in providers if p['type'] not in hide_providers]

    return dict(get_default_context(request),
                providers=providers,
                providers_json=json.dumps(providers),
                saml_providers=request.registry.settings.get(
                    'SOCIAL_AUTH_SAML_ENABLED_IDPS', {}),
                hide_registration=hide_registration,
                identifier = request.params.get('identifier', ''),
                google_consumer_key=request.registry.settings.get(
                    'google.consumer_key', ''),
                next=handle_next_view(request),
                get_route=get_routes)