mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-11 07:46:07 -07:00
Make sure to check server token on login
This commit is contained in:
parent
f66afc4cae
commit
03faebe776
1 changed files with 10 additions and 7 deletions
|
@ -26,18 +26,21 @@ def user_login(username=None, password=None):
|
||||||
|
|
||||||
# Try to login to Plex.tv to check if the user has a vaild account
|
# Try to login to Plex.tv to check if the user has a vaild account
|
||||||
plex_tv = plextv.PlexTV(username=username, password=password)
|
plex_tv = plextv.PlexTV(username=username, password=password)
|
||||||
user = plex_tv.get_token()
|
plex_user = plex_tv.get_token()
|
||||||
if user:
|
if plex_user:
|
||||||
user_token = user['auth_token']
|
user_token = plex_user['auth_token']
|
||||||
user_id = user['user_id']
|
user_id = plex_user['user_id']
|
||||||
|
|
||||||
# Retrieve user token from the database and check against the Plex.tv token.
|
# Retrieve user token from the database and check against the Plex.tv token.
|
||||||
# Also Make sure 'allow_guest' access is enabled for the user.
|
# Also Make sure 'allow_guest' access is enabled for the user.
|
||||||
# The user tokens should match if it is the same PlexPy install.
|
# The user tokens should match if it is the same PlexPy install.
|
||||||
tokens = user_data.get_tokens(user_id=user_id)
|
tokens = user_data.get_tokens(user_id=user_id)
|
||||||
if tokens and tokens['allow_guest'] and user_token == tokens['user_token']:
|
if not tokens:
|
||||||
# Successful login
|
# The user is not in the database
|
||||||
return True
|
return None
|
||||||
|
elif not tokens['allow_guest'] or not user_token == tokens['user_token']:
|
||||||
|
# Guest access is disabled, or user tokens don't match
|
||||||
|
return None
|
||||||
|
|
||||||
# Otherwise it is a new user or token is no longer valid.
|
# Otherwise it is a new user or token is no longer valid.
|
||||||
# Check if the user is in the database, not deleted, and 'allow_guest' access.
|
# Check if the user is in the database, not deleted, and 'allow_guest' access.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue