add new api
This commit is contained in:
@@ -41,7 +41,7 @@ class RegisterApiView(generics.GenericAPIView):
|
||||
data['phone'], data['password'], data['first_name'],
|
||||
data['last_name'], data['email'], 300
|
||||
)
|
||||
user_tasks.create_and_send_sms_code.delay(data['phone'])
|
||||
user_tasks.create_and_send_sms_code.delay(data['phone'], type='auth')
|
||||
return success_message("code is send", 200)
|
||||
return error_message(serializer.errors, 400)
|
||||
|
||||
|
||||
52
core/apps/accounts/views/forgot_password.py
Normal file
52
core/apps/accounts/views/forgot_password.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from rest_framework import generics
|
||||
from rest_framework.response import Response
|
||||
|
||||
from core.apps.accounts.serializers import forgot_password as serializers
|
||||
from core.apps.accounts.tasks.user import create_and_send_sms_code
|
||||
|
||||
class SendCodeApiView(generics.GenericAPIView):
|
||||
serializer_class = serializers.SendCodeSerializer
|
||||
queryset = None
|
||||
|
||||
def post(self, request):
|
||||
serializer = self.serializer_class(data=request.data)
|
||||
if serializer.is_valid(raise_exception=True):
|
||||
data = serializer.data
|
||||
create_and_send_sms_code.delay(data['phone'], 'forgot password')
|
||||
return Response({"success": True, "message": "Kod yuborildi"}, status=201)
|
||||
return Response({"success": False, "message": 'Kod yuborilmadi'}, status=400)
|
||||
|
||||
|
||||
class ConfirmCodeApiView(generics.GenericAPIView):
|
||||
serializer_class = serializers.ConfirmPasswordSerializer
|
||||
queryset = None
|
||||
|
||||
def post(self, request):
|
||||
serializer = self.serializer_class(data=request.data)
|
||||
if serializer.is_valid(raise_exception=True):
|
||||
serializer.save()
|
||||
return Response(
|
||||
{
|
||||
'success': True,
|
||||
"message": "tasdiqlandi"
|
||||
}
|
||||
)
|
||||
return Response({'success': True, "message": serializer.errors})
|
||||
|
||||
|
||||
class ResetPasswordApiView(generics.GenericAPIView):
|
||||
serializer_class = serializers.ResetPasswordSerializer
|
||||
queryset = None
|
||||
|
||||
def post(self, request):
|
||||
serializer = self.serializer_class(data=request.data)
|
||||
if serializer.is_valid(raise_exception=True):
|
||||
serializer.save()
|
||||
return Response(
|
||||
{
|
||||
'success': True,
|
||||
"message": "ozgartirildi"
|
||||
}
|
||||
)
|
||||
return Response({'success': True, "message": serializer.errors})
|
||||
|
||||
Reference in New Issue
Block a user