Anonymous user after successful login
so i am getting AnonymousUser
when printing request.user
after successful login,de-serializing process is done successfully too. Here is my login view class in views.py file:
class LoginView(views.APIView):
def post(self, request):
data = serializers.LoginSerializer(data=request.data)
print(data.is_valid())
print(data.errors)
print(f" HEEERE::: {data}")
if self.request.method == 'POST':
if data.is_valid():
auth = authenticate(
username=data.validated_data['email'], password=data.validated_data['password'])
print(f" email check : {data.validated_data['email']}")
print(f"auth:: {auth}")
if auth is not None:
login(request, auth)
return redirect("/ticket")
else:
return HttpResponse("Invalid Credentials")
else:
return HttpResponse("Data not being validated :O")