Bugfix: enforce PIN for protected users

Bugfix for Plex.tv bug: don't allow protected user to get a token if
pin= in url is omitted
This commit is contained in:
tomkat83 2016-03-07 13:10:38 +01:00
parent c6503f8a8e
commit 4996d7122f

View file

@ -1117,6 +1117,9 @@ class PlexAPI():
else: else:
pin = None pin = None
# Switch to this Plex Home user, if applicable # Switch to this Plex Home user, if applicable
# Plex bug: don't call url for protected user with empty PIN
if user['protected'] == '1' and not pin:
break
username, usertoken = self.PlexSwitchHomeUser( username, usertoken = self.PlexSwitchHomeUser(
user['id'], user['id'],
pin, pin,
@ -1160,8 +1163,7 @@ class PlexAPI():
url = 'https://plex.tv/api/home/users/' + userId + '/switch' url = 'https://plex.tv/api/home/users/' + userId + '/switch'
if pin: if pin:
url += '?pin=' + pin url += '?pin=' + pin
self.logMsg('Switching to user %s with url %s and machineId %s' self.logMsg('Switching to user %s' % userId, 0)
% (userId, url, machineId), 0)
answer = self.TalkToPlexServer(url, talkType="POST", token=token) answer = self.TalkToPlexServer(url, talkType="POST", token=token)
if not answer: if not answer:
self.logMsg('Error: plex.tv switch HomeUser change failed', -1) self.logMsg('Error: plex.tv switch HomeUser change failed', -1)