I am using Django 1.10 with Django-REST.
I need to know if a user is logged in or not (offline / online) How can I do that? I am using token based authentication.
I tried this article but it didn't work for my use case... it seems to be too old
I am using Django 1.10 with Django-REST.
I need to know if a user is logged in or not (offline / online) How can I do that? I am using token based authentication.
I tried this article but it didn't work for my use case... it seems to be too old
Write a piece of Javascript which will send a dummy request to server. Put this to repeat on say 60 or some seconds. As long as you are receiving requests you know page is on. Then you can check if that user is authenticated.
Ok, After trying a few different things I got it. Here's how I made it work:
First create a Middleware to store on memcache the last time the user has accessed the server.
Then extend the User serializer with the properties
online
andlast_seen
Settings.py need to have this new settings:
and do not forget to add your middleware: