Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class RegistrationBackend(SimpleBackend):
def register(self, request, **kwargs):
name, email, password = kwargs['name'], kwargs['email'], kwargs['password1']
username = generate_id(name, '', email)
UserProfile.objects.create(
user=User.objects.create_user(username, email, password),
name=name
)
# authenticate() always has to be called before login(), and
# will return the user we just created.
new_user = authenticate(username=username, password=password)
login(request, new_user)
signals.user_registered.send(sender=self.__class__,
user=new_user,
request=request)
return new_user
def get_form_class(self, request):
return NameAndEmailRegistrationForm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.