Flag update JWT UUID after restarting

This commit is contained in:
JonnyWong16 2019-08-24 21:13:39 -07:00
parent f21d505ab8
commit 7498617b74
4 changed files with 15 additions and 15 deletions

View file

@ -138,15 +138,8 @@ def check_credentials(username=None, password=None, token=None, admin_login='0',
return False, None, None
def jwt_uuid(refresh=False):
if not plexpy.CONFIG.JWT_UUID or refresh:
plexpy.CONFIG.JWT_UUID = plexpy.generate_uuid()
plexpy.CONFIG.write()
return plexpy.CONFIG.JWT_UUID
def check_jwt_token():
jwt_cookie = JWT_COOKIE_NAME + jwt_uuid()
jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.JWT_UUID
jwt_token = cherrypy.request.cookie.get(jwt_cookie)
if jwt_token:
@ -292,7 +285,7 @@ class AuthController(object):
if payload:
self.on_logout(payload['user'], payload['user_group'])
jwt_cookie = JWT_COOKIE_NAME + jwt_uuid()
jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.JWT_UUID
cherrypy.response.cookie[jwt_cookie] = 'expire'
cherrypy.response.cookie[jwt_cookie]['expires'] = 0
cherrypy.response.cookie[jwt_cookie]['path'] = '/'
@ -338,14 +331,14 @@ class AuthController(object):
success=True,
oauth=bool(token))
jwt_cookie = JWT_COOKIE_NAME + jwt_uuid()
jwt_cookie = JWT_COOKIE_NAME + plexpy.CONFIG.JWT_UUID
cherrypy.response.cookie[jwt_cookie] = jwt_token
cherrypy.response.cookie[jwt_cookie]['expires'] = int(time_delta.total_seconds())
cherrypy.response.cookie[jwt_cookie]['path'] = '/'
cherrypy.request.login = payload
cherrypy.response.status = 200
return {'status': 'success', 'token': jwt_token.decode('utf-8'), 'uuid': jwt_uuid()}
return {'status': 'success', 'token': jwt_token.decode('utf-8'), 'uuid': plexpy.CONFIG.JWT_UUID}
elif admin_login == '1' and username:
self.on_login(username=username)