django - is_authenticated returns True for logged out user -
i'm writing server app using django, django rest framework, django-rest-auth , django-allauth. have method that's used pass messages between users, , should happen when receiver logged in.
however, seems user object's is_authenticated()
method returns true though user has logged out (called rest-auth/logout/
, should in turn call django's logout). cause this? there i've missed here?
here's code have:
class sendmessage(generics.createapiview): permission_classes = (permissions.isauthenticated,) serializer_class = messageserializer def perform_create(self, serializer): m = self.request.data['msg'] targetuser = user.objects.get(pk = self.request.data['user']) if targetuser.is_authenticated(): # send message else: # don't send message
unfortunately, is_authenticated() method returns true.
def is_authenticated(self): """ return true. way tell if user has been authenticated in templates. """ return true
it meant discern between user instance , anonymoususer instance, user set when not pass authentication.
Comments
Post a Comment