SMART-31 created endpoint for logging the user
This commit is contained in:
parent
837709d553
commit
5065f040fa
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,3 +2,4 @@
|
|||||||
*.iml
|
*.iml
|
||||||
.idea
|
.idea
|
||||||
*__pycache__/
|
*__pycache__/
|
||||||
|
__pycache__/
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -1,3 +1,27 @@
|
|||||||
from django.shortcuts import render
|
from rest_framework import status
|
||||||
|
from rest_framework.generics import RetrieveAPIView
|
||||||
|
from rest_framework.permissions import AllowAny
|
||||||
|
from rest_framework.response import Response
|
||||||
|
|
||||||
# Create your views here.
|
from smartpicasso.app.user.serializers import UserLoginSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class UserLoginView(RetrieveAPIView):
|
||||||
|
"""
|
||||||
|
View for user login
|
||||||
|
"""
|
||||||
|
permission_classes = (AllowAny,)
|
||||||
|
serializer_class = UserLoginSerializer
|
||||||
|
|
||||||
|
def post(self, request):
|
||||||
|
serializer = self.serializer_class(data=request.data)
|
||||||
|
serializer.is_valid(raise_exception=True)
|
||||||
|
response = {
|
||||||
|
'success': 'True',
|
||||||
|
'status_code': status.HTTP_200_OK,
|
||||||
|
'message': 'User logged in successfully',
|
||||||
|
'token': serializer.data['token']
|
||||||
|
}
|
||||||
|
status_code = status.HTTP_200_OK
|
||||||
|
|
||||||
|
return Response(response, status=status_code)
|
||||||
|
Loading…
Reference in New Issue
Block a user