예제 #1
0
def index(request, view_name=None, start_view=None):
    """Page that serves the static Single Page App (Spartacus)."""
    ctx = {}
    ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)
    jwt = request.GET.get('req')

    if jwt:
        ctx['mkt_user'] = False

    # If this is a Marketplace-issued JWT, verify its signature and skip login
    # for the purchaser named in it.
    if jwt and _get_issuer(jwt) == settings.KEY:
        try:
            data = verify_sig(jwt,
                              settings.SECRET,
                              expected_aud=settings.DOMAIN)
            data = data['request'].get('productData', '')
        except InvalidJWT, exc:
            log.debug(
                'ignoring invalid Marketplace JWT error: {e}'.format(e=exc))
        else:
            product_data = urlparse.parse_qs(data)
            emails = product_data.get('buyer_email')
            if emails:
                log.info("Creating session for marketplace user " +
                         str(emails))
                set_user(request, emails[0], verified=False)
                ctx['mkt_user'] = True
예제 #2
0
파일: views.py 프로젝트: Witia1/webpay
def index(request, view_name=None, start_view=None):
    """Page that serves the static Single Page App (Spartacus)."""
    if not settings.SPA_ENABLE:
        return http.HttpResponseForbidden()
    ctx = {}
    ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)
    jwt = request.GET.get('req')

    if jwt:
        ctx['mkt_user'] = False

    # If this is a Marketplace-issued JWT, verify its signature and skip login
    # for the purchaser named in it.
    if jwt and _get_issuer(jwt) == settings.KEY:
        try:
            data = verify_sig(jwt, settings.SECRET)
            data = data['request'].get('productData', '')
        except InvalidJWT:
            pass
        else:
            product_data = urlparse.parse_qs(data)
            emails = product_data.get('buyer_email')
            if emails:
                log.info("Creating session for marketplace user " +
                         str(emails))
                set_user(request, emails[0], verified=False)
                ctx['mkt_user'] = True

    # This has to come after set_user as set_user modifies the session.
    ctx['super_powers'] = request.session.get('super_powers', False)
    return render(request, 'spa/index.html', ctx)
예제 #3
0
파일: views.py 프로젝트: flodolo/webpay
def index(request, view_name=None, start_view=None):
    """Page that serves the static Single Page App (Spartacus)."""
    ctx = {}
    ctx['fxa_state'], ctx['fxa_auth_url'] = fxa_auth_info(request)
    jwt = request.GET.get('req')

    if jwt:
        ctx['mkt_user'] = False

    # If this is a Marketplace-issued JWT, verify its signature and skip login
    # for the purchaser named in it.
    if jwt and _get_issuer(jwt) == settings.KEY:
        try:
            data = verify_sig(jwt, settings.SECRET,
                              expected_aud=settings.DOMAIN)
            data = data['request'].get('productData', '')
        except InvalidJWT, exc:
            log.debug('ignoring invalid Marketplace JWT error: {e}'
                      .format(e=exc))
        else:
            product_data = urlparse.parse_qs(data)
            emails = product_data.get('buyer_email')
            if emails:
                log.info("Creating session for marketplace user " +
                         str(emails))
                set_user(request, emails[0], verified=False)
                ctx['mkt_user'] = True