Skip to content

Commit

Permalink
[GREEN] Implemented register feature and pass the test.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesSetiawan committed Feb 22, 2024
1 parent 09721ae commit 0d473d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions authentication/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
app_name = 'authentication'

urlpatterns = [
path('register/', RegisterView.as_view(), name='register')
]
12 changes: 7 additions & 5 deletions authentication/views.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
from django.shortcuts import render
import json
from django.http import JsonResponse
from authentication.models import *
from django.views import View
from django.contrib.auth import authenticate, login, logout
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
import re
from django.core.serializers import serialize

@method_decorator(csrf_exempt, name='dispatch')
class RegisterView(View):
def post(self, request):
return 'None'
data = json.loads(request.body)
username = data['username']
password = data['password']
email = data['email']
new_user = AppUser.objects.create_user(email=email,username=username,password=password)
new_user.save()
return JsonResponse({'msg': 'Success! User registered'}, status=200)

0 comments on commit 0d473d8

Please sign in to comment.