瀏覽代碼

Authentication added for the client views

master
kj1352 4 年之前
父節點
當前提交
36c80c8d1e
共有 2 個文件被更改,包括 18 次插入1 次删除
  1. +17
    -1
      client/views.py
  2. +1
    -0
      workx_backend/settings/base.py

+ 17
- 1
client/views.py 查看文件

@@ -1,11 +1,15 @@
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.views import APIView from rest_framework.views import APIView

from rest_framework.authentication import TokenAuthentication
from rest_framework.permissions import IsAuthenticated
from .models import TaxType, Country, State, City, Client from .models import TaxType, Country, State, City, Client
from .serializers import TaxTypeSerializer, CountrySerializer, StateSerializer, CitySerializer, ClientSerializer from .serializers import TaxTypeSerializer, CountrySerializer, StateSerializer, CitySerializer, ClientSerializer




class TaxTypeList(APIView): class TaxTypeList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request): def get(self, request):
tax_types = TaxType.objects.all() tax_types = TaxType.objects.all()
serializer = TaxTypeSerializer(tax_types, many=True) serializer = TaxTypeSerializer(tax_types, many=True)
@@ -13,6 +17,9 @@ class TaxTypeList(APIView):




class CountryList(APIView): class CountryList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request): def get(self, request):
countries = Country.objects.all() countries = Country.objects.all()
serializer = CountrySerializer(countries, many=True) serializer = CountrySerializer(countries, many=True)
@@ -20,6 +27,9 @@ class CountryList(APIView):




class StateList(APIView): class StateList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request): def get(self, request):
states = State.objects.all() states = State.objects.all()
serializer = StateSerializer(states, many=True) serializer = StateSerializer(states, many=True)
@@ -27,6 +37,9 @@ class StateList(APIView):




class CityList(APIView): class CityList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request): def get(self, request):
cities = City.objects.all() cities = City.objects.all()
serializer = CitySerializer(cities, many=True) serializer = CitySerializer(cities, many=True)
@@ -34,6 +47,9 @@ class CityList(APIView):




class ClientList(APIView): class ClientList(APIView):
authentication_classes = [TokenAuthentication]
permission_classes = [IsAuthenticated]

def get(self, request): def get(self, request):
clients = Client.objects.all() clients = Client.objects.all()
serializer = ClientSerializer(clients, many=True) serializer = ClientSerializer(clients, many=True)


+ 1
- 0
workx_backend/settings/base.py 查看文件

@@ -35,6 +35,7 @@ INSTALLED_APPS = [
PASSWORDLESS_AUTH = { PASSWORDLESS_AUTH = {
'PASSWORDLESS_AUTH_TYPES': ['EMAIL'], 'PASSWORDLESS_AUTH_TYPES': ['EMAIL'],
'PASSWORDLESS_EMAIL_NOREPLY_ADDRESS': 'kj@webtrigon.com', 'PASSWORDLESS_EMAIL_NOREPLY_ADDRESS': 'kj@webtrigon.com',
'PASSWORDLESS_REGISTER_NEW_USERS': False,
} }


MIDDLEWARE = [ MIDDLEWARE = [