Some prototyping the registration
This commit is contained in:
parent
36da9c4dd0
commit
ca2d50e26b
3 changed files with 4 additions and 7 deletions
0
api_v1/auth/__init__.py
Normal file
0
api_v1/auth/__init__.py
Normal 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")
|
||||
|
|
|
@ -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'),
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue