-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea8da69
commit 72eaac9
Showing
12 changed files
with
70 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .UserSerializer import UserSerializer |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from django.urls import path | ||
from .views.SignUp import SignUpView | ||
from rest_framework.routers import DefaultRouter | ||
from .views import UserViewSet | ||
|
||
urlpatterns = [ | ||
path('signup/', SignUpView.as_view(), name='signup'), | ||
] | ||
router = DefaultRouter() | ||
router.register(r'register', UserViewSet, basename='user') | ||
|
||
urlpatterns = router.urls |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from rest_framework import viewsets, status | ||
from rest_framework.response import Response | ||
from rest_framework.permissions import AllowAny | ||
from django.contrib.auth.models import User | ||
from ..serializers import UserSerializer | ||
|
||
class UserViewSet(viewsets.ModelViewSet): | ||
""" | ||
A viewset that provides `create` for user registration. | ||
""" | ||
queryset = User.objects.all() | ||
serializer_class = UserSerializer | ||
permission_classes = [AllowAny] | ||
|
||
def create(self, request, *args, **kwargs): | ||
""" | ||
Custom create method for user registration. | ||
""" | ||
serializer = self.get_serializer(data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save() | ||
return Response(serializer.data, status=status.HTTP_201_CREATED) | ||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .UserViewSet import UserViewSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
from django.contrib import admin | ||
from django.urls import path, include | ||
from rest_framework.authtoken import views | ||
from rest_framework_simplejwt.views import ( | ||
TokenObtainPairView, | ||
TokenRefreshView, | ||
) | ||
|
||
|
||
urlpatterns = [ | ||
path('admin/', admin.site.urls), | ||
path('api/', include('dictionary.urls')), | ||
path('api/auth/', views.obtain_auth_token, name='api_token_auth'), | ||
path('api/auth/', include('authentication.urls')), | ||
path('api/auth/login/', TokenObtainPairView.as_view(), name='token_obtain_pair'), | ||
path('api/token/refresh/', TokenRefreshView.as_view(), name='token_refresh'), | ||
path('auth/', include('social_django.urls', namespace='social')), | ||
path('accounts/', include('django.contrib.auth.urls')), | ||
] |