mirror of
https://github.com/Hopiu/django-tos.git
synced 2026-03-16 20:10:24 +00:00
pass used auth backend
This commit is contained in:
parent
c913f06fe1
commit
4310ad2dfe
1 changed files with 5 additions and 0 deletions
|
|
@ -50,6 +50,7 @@ def check_tos(request, template_name='tos/tos_check.html',
|
|||
if request.method=="POST":
|
||||
if request.POST.get("accept", "") == "accept":
|
||||
user = get_user_model().objects.get(pk=request.session['tos_user'])
|
||||
user.backend = request.session['tos_backend']
|
||||
|
||||
# Save the user agreement to the new TOS
|
||||
UserAgreement.objects.create(terms_of_service=tos, user=user)
|
||||
|
|
@ -105,6 +106,10 @@ def login(request, template_name='registration/login.html',
|
|||
# force them to accept or refuse
|
||||
|
||||
request.session['tos_user'] = user.pk
|
||||
# Pass the used backend as well since django will require it
|
||||
# and it can only be optained by calling authenticate, but we got no credentials in check_tos.
|
||||
# see: https://docs.djangoproject.com/en/1.6/topics/auth/default/#how-to-log-a-user-in
|
||||
request.session['tos_backend'] = user.backend
|
||||
|
||||
|
||||
return render_to_response('tos/tos_check.html', {
|
||||
|
|
|
|||
Loading…
Reference in a new issue