Ejemplo n.º 1
0
def bounce(request):
    client, client_id, auth_index, request_data, redirect_url = get_request_data(request)

    # For now, if Focus is down, just say that they're not authenticated.
    # This might not be the best approach, reconsider this.
    response_data = {'er_autentisert': request.user.is_authenticated()}
    if request.user.is_authenticated() and not request.db_connections['focus']['is_available']:
        response_data.update(get_member_data(request.user))

    return prepare_response(client, auth_index, response_data, redirect_url)
Ejemplo n.º 2
0
def signon_complete(request):
    if not 'dntconnect' in request.session:
        # Use a friendlier error message here?
        raise PermissionDenied

    # The signon field should be set in session by whatever service the user used,
    # but it could be missed so check and log any exceptions
    if not 'signon' in request.session['dntconnect']:
        logger.warning(
            "Mangler 'signon' field i session etter vellykket signon",
            extra={
                'request': request,
                'session': request.session,
                'dntconnect': request.session['dntconnect']
            }
        )

    client = settings.DNT_CONNECT[request.session['dntconnect']['client_id']]
    response_data = {
        'er_autentisert': request.user.is_authenticated(),
        'signon': request.session['dntconnect'].get('signon', 'ukjent'),
        'språkkode': request.LANGUAGE_CODE
    }
    if request.user.is_authenticated():
        response_data.update(get_member_data(request.user))
    # Soft get auth_index to support older sessions, can likely be removed after a couple of weeks
    auth_index = request.session['dntconnect'].get('auth_index')
    redirect_url = request.session['dntconnect']['redirect_url']
    del request.session['dntconnect']
    if 'innmelding.aktivitet' in request.session:
        del request.session['innmelding.aktivitet']
    return prepare_response(
        client,
        auth_index,
        response_data,
        redirect_url
    )