From fe93d23747440828e79ce5ed8a25db4ddc8af903 Mon Sep 17 00:00:00 2001 From: Herbert Kruitbosch Date: Fri, 4 May 2018 17:05:18 +0200 Subject: [PATCH] agree create 3 --- rugwebsite/views.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/rugwebsite/views.py b/rugwebsite/views.py index 84d20fb..172950c 100644 --- a/rugwebsite/views.py +++ b/rugwebsite/views.py @@ -3,7 +3,7 @@ import hashlib from django.contrib.auth.decorators import login_required from django.contrib.auth.models import User -from django.shortcuts import render +from django.shortcuts import render, redirect from rugwebsite.forms import RequestGDPRDelete, GDPRAgreeCreate from rugwebsite.models import PendingGDPRAgree, GDPRAgreed, PendingGDPRDelete @@ -48,15 +48,16 @@ def gdpr_create_agree(request): return render(request, 'rugwebsite/gdpr_agree_success.html', {'shownav': True}) else: - assert request.user.is_authenticated(), "User should be authenticated." - data = json.dumps([request.user.username, request.user.first_name, request.user.last_name, request.user.email]) - sha256 = hashlib.sha256() - sha256.update(data.encode('utf-8')) - request.user.delete() - request.session['samlPersoonsgegevensHash'] = sha256.hexdigest() + if request.user.is_authenticated(): + data = json.dumps([request.user.username, request.user.first_name, request.user.last_name, request.user.email]) + sha256 = hashlib.sha256() + sha256.update(data.encode('utf-8')) + request.user.delete() + request.session['samlPersoonsgegevensHash'] = sha256.hexdigest() - form = GDPRAgreeCreate(initial={'data': data}) - return render(request, 'rugwebsite/gdpr.html', {'created': True, 'shownav': True, 'form': form}) + form = GDPRAgreeCreate(initial={'data': data}) + return render(request, 'rugwebsite/gdpr.html', {'created': True, 'shownav': True, 'form': form}) + return redirect('/') def gdpr_request_delete(request):