Invalidate temporary mobile app token after 5 minutes

This commit is contained in:
JonnyWong16 2020-04-12 21:20:14 -07:00
parent b7d03a4f31
commit 400a189455
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 24 additions and 5 deletions

View file

@ -14,6 +14,7 @@
# along with Tautulli. If not, see <http://www.gnu.org/licenses/>.
import time
import threading
import plexpy
import database
@ -22,6 +23,24 @@ import logger
TEMP_DEVICE_TOKEN = None
INVALIDATE_TIMER = None
def set_temp_device_token(token=None):
global TEMP_DEVICE_TOKEN
TEMP_DEVICE_TOKEN = token
if TEMP_DEVICE_TOKEN is not None:
global INVALIDATE_TIMER
if INVALIDATE_TIMER:
INVALIDATE_TIMER.cancel()
invalidate_time = 5 * 60 # 5 minutes
INVALIDATE_TIMER = threading.Timer(invalidate_time, set_temp_device_token, args=[None])
INVALIDATE_TIMER.start()
def get_temp_device_token():
return TEMP_DEVICE_TOKEN
def get_mobile_devices(device_id=None, device_token=None):