mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-10-23 09:37:56 +00:00
authenticate the api
This commit is contained in:
@@ -208,6 +208,7 @@ class ResetPasswordAPIView(views.APIView):
|
||||
|
||||
class ForgotPasswordAPIView(views.APIView):
|
||||
"""Forgot password"""
|
||||
|
||||
def post(self, request):
|
||||
serializer = ForgotPasswordSerializer(data=request.data)
|
||||
if serializer.is_valid():
|
||||
@@ -346,6 +347,7 @@ class UserEmailVerification(viewsets.ModelViewSet):
|
||||
"""User Email verification"""
|
||||
serializer_class = EmailVerificationSerializer
|
||||
queryset = UserEmailOtp.objects.all()
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
try:
|
||||
@@ -389,6 +391,8 @@ class ReSendEmailOtp(viewsets.ModelViewSet):
|
||||
"""Send otp on phone"""
|
||||
queryset = UserEmailOtp.objects.all()
|
||||
serializer_class = EmailVerificationSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
otp = generate_otp()
|
||||
if User.objects.filter(email=request.data['email']):
|
||||
@@ -410,6 +414,8 @@ class ProfileAPIViewSet(viewsets.ModelViewSet):
|
||||
"""Profile viewset"""
|
||||
queryset = User.objects.all()
|
||||
serializer_class = JuniorProfileSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
"""profile view"""
|
||||
if str(self.request.GET.get('user_type')) == '1':
|
||||
@@ -448,6 +454,7 @@ class DefaultImageAPIViewSet(viewsets.ModelViewSet):
|
||||
"""Profile viewset"""
|
||||
queryset = DefaultTaskImages.objects.all()
|
||||
serializer_class = DefaultTaskImagesDetailsSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
def list(self, request, *args, **kwargs):
|
||||
"""profile view"""
|
||||
queryset = DefaultTaskImages.objects.all()
|
||||
@@ -478,6 +485,7 @@ class UserNotificationAPIViewSet(viewsets.ModelViewSet):
|
||||
"""notification viewset"""
|
||||
queryset = UserNotification.objects.all()
|
||||
serializer_class = UserNotificationSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
def list(self, request, *args, **kwargs):
|
||||
"""profile view"""
|
||||
queryset = self.queryset.filter(user=request.user)
|
||||
@@ -489,6 +497,7 @@ class UpdateUserNotificationAPIViewSet(viewsets.ModelViewSet):
|
||||
"""Update notification viewset"""
|
||||
queryset = UserNotification.objects.all()
|
||||
serializer_class = UpdateUserNotificationSerializer
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def create(self, request, *args, **kwargs):
|
||||
"""profile view"""
|
||||
@@ -502,6 +511,8 @@ class UpdateUserNotificationAPIViewSet(viewsets.ModelViewSet):
|
||||
|
||||
class SendSupportEmail(views.APIView):
|
||||
"""support email api"""
|
||||
permission_classes = (IsAuthenticated,)
|
||||
|
||||
def post(self, request):
|
||||
name = request.data.get('name')
|
||||
sender = request.data.get('email')
|
||||
|
||||
@@ -62,6 +62,8 @@ class JuniorListAPIView(viewsets.ModelViewSet):
|
||||
|
||||
serializer_class = JuniorDetailListSerializer
|
||||
queryset = Junior.objects.all()
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
""" junior list"""
|
||||
guardian_data = Guardian.objects.filter(user__email=request.user).last()
|
||||
|
||||
Reference in New Issue
Block a user