mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-14 01:02:59 -07:00
Update guest access for collection and playlist changes
This commit is contained in:
parent
3cc8c1f8c5
commit
c8b0ff22f6
8 changed files with 407 additions and 373 deletions
|
@ -143,7 +143,7 @@ def has_library_type(section_type):
|
|||
|
||||
|
||||
def get_collections(section_id):
|
||||
plex = Plex(plexpy.CONFIG.PMS_URL, plexpy.CONFIG.PMS_TOKEN)
|
||||
plex = Plex(plexpy.CONFIG.PMS_URL, session.get_session_user_token())
|
||||
library = plex.get_library(section_id)
|
||||
|
||||
if library.type not in ('movie', 'show', 'artist'):
|
||||
|
@ -231,7 +231,7 @@ def get_collections_list(section_id=None, **kwargs):
|
|||
|
||||
|
||||
def get_playlists(section_id):
|
||||
plex = Plex(plexpy.CONFIG.PMS_URL, plexpy.CONFIG.PMS_TOKEN)
|
||||
plex = Plex(plexpy.CONFIG.PMS_URL, session.get_session_user_token())
|
||||
|
||||
library = Libraries().get_details(section_id=section_id)
|
||||
|
||||
|
|
|
@ -3020,8 +3020,7 @@ class SCRIPTS(Notifier):
|
|||
|
||||
if user_id:
|
||||
user_tokens = users.Users().get_tokens(user_id=user_id)
|
||||
if user_tokens and user_tokens['server_token']:
|
||||
custom_env['PLEX_USER_TOKEN'] = str(user_tokens['server_token'])
|
||||
custom_env['PLEX_USER_TOKEN'] = str(user_tokens['server_token'])
|
||||
|
||||
if self.pythonpath and plexpy.INSTALL_TYPE not in ('windows', 'macos'):
|
||||
custom_env['PYTHONPATH'] = os.pathsep.join([p for p in sys.path if p])
|
||||
|
|
|
@ -57,6 +57,22 @@ def get_session_user_id():
|
|||
_session = get_session_info()
|
||||
return str(_session['user_id']) if _session['user_group'] == 'guest' and _session['user_id'] else None
|
||||
|
||||
|
||||
def get_session_user_token():
|
||||
"""
|
||||
Returns the user's server_token for the current logged in session
|
||||
"""
|
||||
_session = get_session_info()
|
||||
|
||||
if _session['user_group'] == 'guest' and _session['user_id']:
|
||||
session_user_tokens = users.Users().get_tokens(_session['user_id'])
|
||||
user_token = session_user_tokens['server_token']
|
||||
else:
|
||||
user_token = plexpy.CONFIG.PMS_TOKEN
|
||||
|
||||
return user_token
|
||||
|
||||
|
||||
def get_session_shared_libraries():
|
||||
"""
|
||||
Returns a tuple of section_id for the current logged in session
|
||||
|
|
|
@ -787,6 +787,12 @@ class Users(object):
|
|||
return session.friendly_name_to_username(result)
|
||||
|
||||
def get_tokens(self, user_id=None):
|
||||
tokens = {
|
||||
'allow_guest': 0,
|
||||
'user_token': '',
|
||||
'server_token': ''
|
||||
}
|
||||
|
||||
if user_id:
|
||||
try:
|
||||
monitor_db = database.MonitorDatabase()
|
||||
|
@ -800,11 +806,11 @@ class Users(object):
|
|||
}
|
||||
return tokens
|
||||
else:
|
||||
return None
|
||||
return tokens
|
||||
except:
|
||||
return None
|
||||
return tokens
|
||||
|
||||
return None
|
||||
return tokens
|
||||
|
||||
def get_filters(self, user_id=None):
|
||||
if not user_id:
|
||||
|
|
|
@ -845,7 +845,7 @@ class WebInterface(object):
|
|||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
@requireAuth()
|
||||
@addtoapi("get_collections_table")
|
||||
def get_collections_list(self, section_id=None, **kwargs):
|
||||
""" Get the data on the Tautulli collections tables.
|
||||
|
@ -882,7 +882,7 @@ class WebInterface(object):
|
|||
|
||||
@cherrypy.expose
|
||||
@cherrypy.tools.json_out()
|
||||
@requireAuth(member_of("admin"))
|
||||
@requireAuth()
|
||||
@addtoapi("get_playlists_table")
|
||||
def get_playlists_list(self, section_id=None, **kwargs):
|
||||
""" Get the data on the Tautulli playlists tables.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue