From 5065f040fadc7160e8fc4e66a8a686c3579b1361 Mon Sep 17 00:00:00 2001 From: s460930 Date: Tue, 1 Dec 2020 18:01:35 +0100 Subject: [PATCH] SMART-31 created endpoint for logging the user --- .gitignore | 1 + .../__pycache__/settings.cpython-38.pyc | Bin 2374 -> 3500 bytes .../__pycache__/wsgi.cpython-38.pyc | Bin 593 -> 580 bytes rest-app/smartpicasso/app/user/views.py | 28 ++++++++++++++++-- 4 files changed, 27 insertions(+), 2 deletions(-) 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 caacdb3dd9d64236575420a8d2c9694e6624cc36..7445662b07835205a8b61749dc56b8b4e51a7f35 100644 GIT binary patch delta 1521 zcmaJ>OLH4V5Z+m>o{?X&Y$vvHAO;h~MnH(eD*-mrDB5_fRqd{#crL@nJ*?N!t5$NQ z;)@QPIr(a;pg2**1@afD{0LpCqKX?QE>tD-t{h8Ah-YeMr@O!Yx_ch`B=gHszcw+E zlCVAQJmGsYlJrL)jJG)yzQWO6B$5OYlYoHSAWfOcBv?lpk*2~FA_+xAza>A!ew6m( z`*D^4g(V@%Qm(|#K@8%MfFz{g9He2wO|Udf!W8tUVFofV3t2bLCSZ=8BtmtYk!m*DMiekYvQJmM-W1Mjj~ zxXiMc$Q+J&91DX`5I1# zSA5a!@o#*mDIT`{2lRLBd!p6zcAcJp!?m-q(DYg%=ZzO}eE(rD z?~IuGNS?oA8I`)YZ?_+a)>srY<*@i7EvYr#=2dELYnG)M6<*L)%c2%rd2Ul{c9~Xe zt)SXt_QUo634YM?8r?jm!9{Dg-3P(-j0)?vI zHcZVfZ?jY&-le8i+F^5}HK+HgnyK1-ye>nGPHA1;Vc7t4VhpZQk?OX}(jjTBsNw$5 zAs(+{4R>fJwCK7~$LdO0V40ni8Vavc%@3*UGA~oL_$BUA6&^3@{ISyi4=bS{0|Laz;gfq delta 385 zcmYk2yG{Z@6ozMJhuvi_at9Gb@Pc5a4`5=VG@2MAn&>nu`jc@93W9|lg^#e&iWn_T z?05kS^&x0|4lg4%{wM#J^XHu6!7@)gcMxq;d*nkw&FPD$Dg%N{F@DtY64>p*K9FD|C3vJ~e6%1HD8uJC)4H@I16n zJ#S=m>Q`qi|D?-;OS|lhtXg$rue$GTSC4{w`!)PTx_R}MZa%nkj-%JA<&L984X$y< a^}ux3Y=coo^)LR--C)5Al$V!_0SG!GHga8KWDK4BkkN6nD3d+_Z2Jdz 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)