Add: make userProfile on sign up

This commit is contained in:
Aroy-Art 2023-11-10 10:13:04 +01:00
parent cc4523b427
commit 73b4e26372
Signed by: Aroy
GPG key ID: 583642324A1D2070

View file

@ -1,6 +1,10 @@
# Create your views here.
from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login
#from django.contrib.auth.models import User
from apps.user.models import UserProfile
from .forms import LoginForm, SignUpForm
@ -41,6 +45,12 @@ def register_user(request):
username = form.cleaned_data.get("username")
raw_password = form.cleaned_data.get("password1")
user = authenticate(username=username, password=raw_password)
#user = User.objects.create_user(username=username, password=raw_password)
# Create a UserProfile instance for the user
profile = UserProfile(user=user)
profile.save()
msg = 'User created - please <a href="/login">login</a>.'
success = True