Only sign user out if 401 returned

- Fixes #156
This commit is contained in:
tomkat83 2016-12-17 12:52:25 +01:00
parent 0ee43e2297
commit a14494d96d

View file

@ -157,7 +157,7 @@ class UserClient(threading.Thread):
return False return False
elif res == 401: elif res == 401:
log.warn('Token is no longer valid') log.warn('Token is no longer valid')
return False return 401
elif res >= 400: elif res >= 400:
log.error('Answer from PMS is not as expected. Retrying') log.error('Answer from PMS is not as expected. Retrying')
return False return False
@ -244,18 +244,21 @@ class UserClient(threading.Thread):
# Found a user in the settings, try to authenticate # Found a user in the settings, try to authenticate
if username and enforceLogin == 'false': if username and enforceLogin == 'false':
log.info('Trying to authenticate with old settings') log.info('Trying to authenticate with old settings')
if self.loadCurrUser(username, answ = self.loadCurrUser(username,
userId, userId,
usertoken, usertoken,
authenticated=False): authenticated=False)
if answ is True:
# SUCCESS: loaded a user from the settings # SUCCESS: loaded a user from the settings
return True return True
else: elif answ == 401:
# Failed to use the settings - delete them! log.info("User token no longer valid. Sign user out")
log.info("Failed to use settings credentials. Deleting them")
settings('username', value='') settings('username', value='')
settings('userid', value='') settings('userid', value='')
settings('accessToken', value='') settings('accessToken', value='')
else:
log.info("Could not yet authenticate user")
return False
plx = PlexAPI.PlexAPI() plx = PlexAPI.PlexAPI()