diff --git a/.gitignore b/.gitignore index 50f3221..3269869 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ *.iml .idea *__pycache__/ +__pycache__/ diff --git a/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc index caacdb3..7445662 100644 Binary files a/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc and b/rest-app/smartpicasso/__pycache__/settings.cpython-38.pyc differ diff --git a/rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc b/rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc index 87f6c23..4baa4a5 100644 Binary files a/rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc and b/rest-app/smartpicasso/__pycache__/wsgi.cpython-38.pyc differ diff --git a/rest-app/smartpicasso/app/user/views.py b/rest-app/smartpicasso/app/user/views.py index 91ea44a..a303436 100644 --- a/rest-app/smartpicasso/app/user/views.py +++ b/rest-app/smartpicasso/app/user/views.py @@ -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)