Add API routes for Spaceport auth
This commit is contained in:
parent
6603eb56ac
commit
9a105908a3
|
@ -7,7 +7,7 @@ from rest_framework import serializers
|
||||||
from rest_framework.exceptions import ValidationError
|
from rest_framework.exceptions import ValidationError
|
||||||
from rest_framework.validators import UniqueValidator
|
from rest_framework.validators import UniqueValidator
|
||||||
from rest_auth.registration.serializers import RegisterSerializer
|
from rest_auth.registration.serializers import RegisterSerializer
|
||||||
from rest_auth.serializers import PasswordChangeSerializer, PasswordResetSerializer, PasswordResetConfirmSerializer
|
from rest_auth.serializers import PasswordChangeSerializer, PasswordResetSerializer, PasswordResetConfirmSerializer, LoginSerializer
|
||||||
from rest_auth.serializers import UserDetailsSerializer
|
from rest_auth.serializers import UserDetailsSerializer
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -545,3 +545,10 @@ class HistorySerializer(serializers.ModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = models.HistoryIndex
|
model = models.HistoryIndex
|
||||||
fields = '__all__'
|
fields = '__all__'
|
||||||
|
|
||||||
|
class SpaceportAuthSerializer(LoginSerializer):
|
||||||
|
def authenticate(self, **kwargs):
|
||||||
|
result = super().authenticate(**kwargs)
|
||||||
|
print(result)
|
||||||
|
print(self.context['request'].data)
|
||||||
|
return result
|
||||||
|
|
|
@ -12,7 +12,7 @@ from rest_framework import viewsets, views, mixins, generics, exceptions
|
||||||
from rest_framework.decorators import action, api_view
|
from rest_framework.decorators import action, api_view
|
||||||
from rest_framework.permissions import BasePermission, IsAuthenticated, SAFE_METHODS, IsAuthenticatedOrReadOnly
|
from rest_framework.permissions import BasePermission, IsAuthenticated, SAFE_METHODS, IsAuthenticatedOrReadOnly
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_auth.views import PasswordChangeView, PasswordResetView, PasswordResetConfirmView
|
from rest_auth.views import PasswordChangeView, PasswordResetView, PasswordResetConfirmView, LoginView
|
||||||
from rest_auth.registration.views import RegisterView
|
from rest_auth.registration.views import RegisterView
|
||||||
from fuzzywuzzy import fuzz, process
|
from fuzzywuzzy import fuzz, process
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
@ -604,6 +604,9 @@ class PasswordResetView(PasswordResetView):
|
||||||
class PasswordResetConfirmView(PasswordResetConfirmView):
|
class PasswordResetConfirmView(PasswordResetConfirmView):
|
||||||
serializer_class = serializers.MyPasswordResetConfirmSerializer
|
serializer_class = serializers.MyPasswordResetConfirmSerializer
|
||||||
|
|
||||||
|
class SpaceportAuthView(LoginView):
|
||||||
|
serializer_class = serializers.SpaceportAuthSerializer
|
||||||
|
|
||||||
|
|
||||||
@api_view()
|
@api_view()
|
||||||
def null_view(request, *args, **kwargs):
|
def null_view(request, *args, **kwargs):
|
||||||
|
|
|
@ -33,6 +33,7 @@ urlpatterns = [
|
||||||
path('', include(router.urls)),
|
path('', include(router.urls)),
|
||||||
path(ADMIN_ROUTE, admin.site.urls),
|
path(ADMIN_ROUTE, admin.site.urls),
|
||||||
url(r'^rest-auth/login/$', LoginView.as_view(), name='rest_login'),
|
url(r'^rest-auth/login/$', LoginView.as_view(), name='rest_login'),
|
||||||
|
url(r'^spaceport-auth/login/$', views.SpaceportAuthView.as_view(), name='spaceport_auth'),
|
||||||
url(r'^rest-auth/logout/$', LogoutView.as_view(), name='rest_logout'),
|
url(r'^rest-auth/logout/$', LogoutView.as_view(), name='rest_logout'),
|
||||||
url(r'^password/reset/$', views.PasswordResetView.as_view(), name='rest_password_reset'),
|
url(r'^password/reset/$', views.PasswordResetView.as_view(), name='rest_password_reset'),
|
||||||
url(r'^password/reset/confirm/$', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
|
url(r'^password/reset/confirm/$', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user