Commit 28fc608f authored by David Seaward's avatar David Seaward
Browse files

Refactor user creation function for debugging.

Signed-off-by: David Seaward's avatarDavid Seaward <>
parent caa46a90
Pipeline #4624 failed with stage
from django import forms
from django.contrib.auth import get_user_model
from django.conf import settings
from django.contrib.auth import authenticate, login
from registration import signals
from registration.backends.simple.views import RegistrationView
from ldapregister.forms import RegistrationForm
from captcha.fields import CaptchaField
from cart.models import ChosenReward
User = get_user_model()
class CartRegistrationForm(RegistrationForm):
captcha = CaptchaField()
......@@ -27,7 +32,19 @@ class CartRegistrationView(RegistrationView):
def register(self, form):
usr = super().register(form)
reward = ChosenReward(user=usr, reward=self.reward)
# we ignore super().register(form) and replicate it here
new_user =
reward = ChosenReward(user=new_user, reward=self.reward)
return usr
new_user = authenticate(
username=getattr(new_user, User.USERNAME_FIELD),
login(self.request, new_user)
return new_user
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment