agree create 3

This commit is contained in:
H.T. Kruitbosch 2018-05-04 17:09:13 +02:00
parent fe93d23747
commit 0e2901b62b
2 changed files with 8 additions and 4 deletions

View File

@ -8,3 +8,5 @@ urlpatterns = [
url(r'', include(saml_urls, namespace='saml')), url(r'', include(saml_urls, namespace='saml')),
url(r'$', home), url(r'$', home),
] ]
import django.contrib.auth

View File

@ -1,6 +1,7 @@
import json import json
import hashlib import hashlib
from django.contrib.auth import login
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
@ -41,10 +42,11 @@ def gdpr_create_agree(request):
sha256 = hashlib.sha256() sha256 = hashlib.sha256()
sha256.update(data.encode('utf-8')) sha256.update(data.encode('utf-8'))
assert request.session.get('samlPersoonsgegevensHash', None) == sha256.hexdigest(), "Persoonsgegevens have been tinkered with" assert request.session.get('samlPersoonsgegevensHash', None) == sha256.hexdigest(), "Persoonsgegevens have been tinkered with"
request.user = User() user = User()
request.user.username, request.user.first_name, request.user.last_name, request.user.email = json.loads(data) user.username, user.first_name, user.last_name, user.email = json.loads(data)
request.user.is_active = True user.is_active = True
request.user.save() user.save()
login(request, user, backend=None)
return render(request, 'rugwebsite/gdpr_agree_success.html', {'shownav': True}) return render(request, 'rugwebsite/gdpr_agree_success.html', {'shownav': True})
else: else: