Fix django-rest-auth's bugs so API works (lol...)
This commit is contained in:
parent
e7eed9b3b0
commit
6992114ce6
|
@ -3,7 +3,9 @@ from django.shortcuts import render
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from caremyway.api.models import UserInfo, Client, Provider
|
from caremyway.api.models import UserInfo, Client, Provider
|
||||||
from rest_framework import viewsets, permissions
|
from rest_framework import viewsets, permissions, status
|
||||||
|
from rest_framework.decorators import api_view
|
||||||
|
from rest_framework.response import Response
|
||||||
from caremyway.api.serializers import UserSerializer, UserInfoSerializer, ClientSerializer, ProviderSerializer
|
from caremyway.api.serializers import UserSerializer, UserInfoSerializer, ClientSerializer, ProviderSerializer
|
||||||
|
|
||||||
class UserViewSet(viewsets.ModelViewSet):
|
class UserViewSet(viewsets.ModelViewSet):
|
||||||
|
@ -16,3 +18,7 @@ class UserViewSet(viewsets.ModelViewSet):
|
||||||
return User.objects.all().order_by('-date_joined')
|
return User.objects.all().order_by('-date_joined')
|
||||||
else:
|
else:
|
||||||
return User.objects.filter(username=user)
|
return User.objects.filter(username=user)
|
||||||
|
|
||||||
|
@api_view()
|
||||||
|
def null_view(request):
|
||||||
|
return Response(status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
|
@ -53,8 +53,10 @@ SITE_ID = 1
|
||||||
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
|
|
||||||
ACCOUNT_AUTHENTICATION_METHOD = 'email'
|
ACCOUNT_AUTHENTICATION_METHOD = 'email'
|
||||||
|
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
|
||||||
ACCOUNT_EMAIL_REQUIRED = True
|
ACCOUNT_EMAIL_REQUIRED = True
|
||||||
ACCOUNT_USERNAME_REQUIRED = False
|
ACCOUNT_USERNAME_REQUIRED = False
|
||||||
|
OLD_PASSWORD_FIELD_ENABLED = True
|
||||||
|
|
||||||
#Following is added to enable registration with email instead of username
|
#Following is added to enable registration with email instead of username
|
||||||
AUTHENTICATION_BACKENDS = (
|
AUTHENTICATION_BACKENDS = (
|
||||||
|
|
|
@ -25,6 +25,9 @@ router.register(r'users', views.UserViewSet, 'user')
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^', include(router.urls)),
|
url(r'^', include(router.urls)),
|
||||||
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
||||||
|
url(r'^rest-auth/registration/account-email-verification-sent/', views.null_view, name='account_email_verification_sent'),
|
||||||
|
url(r'^rest-auth/registration/account-confirm-email/', views.null_view, name='account_confirm_email'),
|
||||||
|
url(r'^password-reset/confirm/(?P<uidb64>[0-9A-Za-z_\-]+)/(?P<token>[0-9A-Za-z]{1,13}-[0-9A-Za-z]{1,20})/$', views.null_view, name='password_reset_confirm'),
|
||||||
url(r'^rest-auth/', include('rest_auth.urls')),
|
url(r'^rest-auth/', include('rest_auth.urls')),
|
||||||
url(r'^rest-auth/registration/', include('rest_auth.registration.urls'))
|
url(r'^rest-auth/registration/', include('rest_auth.registration.urls'))
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user