Some prototyping the registration

This commit is contained in:
Maximilian Giller 2024-02-29 00:06:45 +01:00
parent 36da9c4dd0
commit ca2d50e26b
3 changed files with 4 additions and 7 deletions

0
api_v1/auth/__init__.py Normal file
View file

View file

@ -1,7 +1,7 @@
from django.views import View
from django.contrib.auth.models import User
from django.http import HttpResponse
from api_v1.user.user_services import acreate_user_information
from api_v1.profile.profile_services import acreate_profile
class RegistrationView(View):
@ -12,14 +12,14 @@ class RegistrationView(View):
email = request.POST.get('email')
display_name = request.POST.get('display_name')
# Check if user already exists
# Check if profile already exists
if User.objects.filter(username=username).exists():
return HttpResponse(status=400, content="User already exists")
# Create user
# Create profile
user = await User.objects.acreate_user(username, email, password)
# Create UserInformation
await acreate_user_information(user, display_name=display_name)
await acreate_profile(user, display_name=display_name)
return HttpResponse(status=201, content="User created")

View file

@ -1,8 +1,5 @@
from django.urls import path, include
from .auth.registration_view import RegistrationView
# Assign register url
urlpatterns = [
path("auth/", include("django.contrib.auth.urls")),
path('auth/register/', RegistrationView.as_view(), name='register'),
]