mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-16 02:02:58 -07:00
Add global allow guest access setting and per user toggles
This commit is contained in:
parent
4be41336b3
commit
62600a450a
7 changed files with 56 additions and 15 deletions
|
@ -20,6 +20,7 @@ is_allow_sync Returns bool value for whether the user has sync rights.
|
|||
is_restricted Returns bool value for whether the user account is restricted.
|
||||
do_notify Returns bool value for whether to send notifications for the user.
|
||||
keep_history Returns bool value for whether to keep history for the user.
|
||||
allow_guest Returns bool value for whether to allow guest access for the user.
|
||||
|
||||
DOCUMENTATION :: END
|
||||
</%doc>
|
||||
|
@ -67,6 +68,12 @@ DOCUMENTATION :: END
|
|||
</label>
|
||||
<p class="help-block">Uncheck this if you do not want to keep any history on this user's activity.</p>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="allow_guest" name="allow_guest" value="1" ${helpers.checked(data['allow_guest'])}> Allow Guest Access
|
||||
</label>
|
||||
<p class="help-block">Uncheck this if you do not want to allow this user to login to PlexPy.</p>
|
||||
</div>
|
||||
% if data['user_id']:
|
||||
<div class="form-group">
|
||||
<button class="btn btn-danger" id="delete-all-history">Purge</button>
|
||||
|
@ -108,12 +115,16 @@ DOCUMENTATION :: END
|
|||
var custom_thumb = $("#custom_avatar_url").val();
|
||||
var do_notify = 0;
|
||||
var keep_history = 0;
|
||||
var allow_guest = 0;
|
||||
if ($("#do_notify").is(":checked")) {
|
||||
do_notify = 1;
|
||||
}
|
||||
if ($("#keep_history").is(":checked")) {
|
||||
keep_history = 1;
|
||||
}
|
||||
if ($("#allow_guest").is(":checked")) {
|
||||
allow_guest = 1;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: 'edit_user',
|
||||
|
@ -122,7 +133,8 @@ DOCUMENTATION :: END
|
|||
friendly_name: friendly_name,
|
||||
custom_thumb: custom_thumb,
|
||||
do_notify: do_notify,
|
||||
keep_history: keep_history
|
||||
keep_history: keep_history,
|
||||
allow_guest: allow_guest
|
||||
},
|
||||
cache: false,
|
||||
async: true,
|
||||
|
|
|
@ -45,6 +45,7 @@ users_list_table_options = {
|
|||
'<button class="btn btn-xs btn-warning purge-user" data-id="' + rowData['user_id'] + '" data-toggle="button"><i class="fa fa-eraser fa-fw"></i> Purge</button>   ' +
|
||||
'<input type="checkbox" id="do_notify-' + rowData['user_id'] + '" name="do_notify" value="1" ' + rowData['do_notify'] + '><label class="edit-tooltip" for="do_notify-' + rowData['user_id'] + '" data-toggle="tooltip" title="Toggle Notifications"><i class="fa fa-bell fa-lg fa-fw"></i></label> ' +
|
||||
'<input type="checkbox" id="keep_history-' + rowData['user_id'] + '" name="keep_history" value="1" ' + rowData['keep_history'] + '><label class="edit-tooltip" for="keep_history-' + rowData['user_id'] + '" data-toggle="tooltip" title="Toggle History"><i class="fa fa-history fa-lg fa-fw"></i></label> ' +
|
||||
'<input type="checkbox" id="allow_guest-' + rowData['user_id'] + '" name="allow_guest" value="1" ' + rowData['allow_guest'] + '><label class="edit-tooltip" for="allow_guest-' + rowData['user_id'] + '" data-toggle="tooltip" title="Allow Guest Access"><i class="fa fa-unlock-alt fa-lg fa-fw"></i></label> ' +
|
||||
'</div>');
|
||||
},
|
||||
"width": "7%",
|
||||
|
@ -300,12 +301,16 @@ $('#users_list_table').on('change', 'td.edit-control > .edit-user-toggles > inpu
|
|||
|
||||
var do_notify = 0;
|
||||
var keep_history = 0;
|
||||
var allow_guest = 0;
|
||||
if ($('#do_notify-' + rowData['user_id']).is(':checked')) {
|
||||
do_notify = 1;
|
||||
}
|
||||
if ($('#keep_history-' + rowData['user_id']).is(':checked')) {
|
||||
keep_history = 1;
|
||||
}
|
||||
if ($('#allow_guest-' + rowData['user_id']).is(':checked')) {
|
||||
allow_guest = 1;
|
||||
}
|
||||
|
||||
friendly_name = tr.find('td.edit-user-control > .edit-user-name > input').val();
|
||||
|
||||
|
@ -316,6 +321,7 @@ $('#users_list_table').on('change', 'td.edit-control > .edit-user-toggles > inpu
|
|||
friendly_name: friendly_name,
|
||||
do_notify: do_notify,
|
||||
keep_history: keep_history,
|
||||
allow_guest: allow_guest,
|
||||
thumb: rowData['user_thumb']
|
||||
},
|
||||
cache: false,
|
||||
|
|
|
@ -520,6 +520,16 @@ available_notification_agents = sorted(notifiers.available_notification_agents()
|
|||
data-parsley-errors-container="#http_hash_password_error" data-parsley-error-message="Cannot un-hash password, please set a new password." data-parsley-no-focus required>
|
||||
|
||||
|
||||
<div class="padded-header">
|
||||
<h3>Guest Access</h3>
|
||||
</div>
|
||||
<div class="checkbox">
|
||||
<label>
|
||||
<input type="checkbox" id="allow_guest_access" name="allow_guest_access" value="1" ${config['allow_guest_access']}> Allow Guest Access to PlexPy
|
||||
</label>
|
||||
<p class="help-block">Allow shared users to login to PlexPy using their Plex.tv account.</p>
|
||||
</div>
|
||||
|
||||
<div class="padded-header">
|
||||
<h3>API</h3>
|
||||
</div>
|
||||
|
|
|
@ -13,6 +13,7 @@ def bool_int(value):
|
|||
return int(bool(value))
|
||||
|
||||
_CONFIG_DEFINITIONS = {
|
||||
'ALLOW_GUEST_ACCESS': (int, 'General', 0),
|
||||
'DATE_FORMAT': (str, 'General', 'YYYY-MM-DD'),
|
||||
'GROUPING_GLOBAL_HISTORY': (int, 'PlexWatch', 0),
|
||||
'GROUPING_USER_HISTORY': (int, 'PlexWatch', 0),
|
||||
|
|
|
@ -39,9 +39,10 @@ def user_login(username=None, password=None):
|
|||
return True
|
||||
|
||||
# Otherwise it is a new user or token is no longer valid.
|
||||
# Check if the user is in the database.
|
||||
# Check if the user is in the database, not deleted, and 'allow_guest' access.
|
||||
user_details = user_data.get_details(user_id=user_id)
|
||||
if user_details['allow_guest'] and user_id == str(user_details['user_id']):
|
||||
if user_id == str(user_details['user_id']) and \
|
||||
not user_details['deleted_user'] and user_details['allow_guest']:
|
||||
|
||||
# The user is in the database, so try to retrieve a new server token.
|
||||
# If a server token is returned, then the user is a vaild friend
|
||||
|
@ -53,21 +54,26 @@ def user_login(username=None, password=None):
|
|||
monitor_db = database.MonitorDatabase()
|
||||
try:
|
||||
logger.debug(u"PlexPy Users :: Regestering tokens for user '%s' in the database." % username)
|
||||
monitor_db.action('UPDATE users SET user_token = ?, server_token = ? WHERE user_id = ?',
|
||||
[user_token, server_token, user_id])
|
||||
# Successful login
|
||||
return True
|
||||
result = monitor_db.action('UPDATE users SET user_token = ?, server_token = ? WHERE user_id = ?',
|
||||
[user_token, server_token, user_id])
|
||||
|
||||
if result:
|
||||
# Successful login
|
||||
return True
|
||||
else:
|
||||
logger.warn(u"PlexPy Users :: Unable to register user '%s' in database." % username)
|
||||
return None
|
||||
except Exception as e:
|
||||
logger.warn(u"PlexPy Users :: Unable to register user '%s' in database: %s." % (username, e))
|
||||
return None
|
||||
else:
|
||||
logger.warn(u"PlexPy Users :: Unable to retrieve Plex.tv server token.")
|
||||
logger.warn(u"PlexPy Users :: Unable to retrieve Plex.tv server token for user '%s'." % username)
|
||||
return None
|
||||
else:
|
||||
logger.warn(u"PlexPy Users :: Unable to register user '%s'. User not in the database." % username)
|
||||
return None
|
||||
else:
|
||||
logger.warn(u"PlexPy Users :: Unable to retrieve Plex.tv user token.")
|
||||
logger.warn(u"PlexPy Users :: Unable to retrieve Plex.tv user token for user '%s'." % username)
|
||||
return None
|
||||
|
||||
return None
|
||||
|
@ -341,13 +347,13 @@ class Users(object):
|
|||
try:
|
||||
if str(user_id).isdigit():
|
||||
query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \
|
||||
'email, is_home_user, is_allow_sync, is_restricted, do_notify, keep_history, allow_guest ' \
|
||||
'email, is_home_user, is_allow_sync, is_restricted, do_notify, keep_history, deleted_user, allow_guest ' \
|
||||
'FROM users ' \
|
||||
'WHERE user_id = ? '
|
||||
result = monitor_db.select(query, args=[user_id])
|
||||
elif user:
|
||||
query = 'SELECT user_id, username, friendly_name, thumb AS user_thumb, custom_avatar_url AS custom_thumb, ' \
|
||||
'email, is_home_user, is_allow_sync, is_restricted, do_notify, keep_history, allow_guest ' \
|
||||
'email, is_home_user, is_allow_sync, is_restricted, do_notify, keep_history, deleted_user, allow_guest ' \
|
||||
'FROM users ' \
|
||||
'WHERE username = ? '
|
||||
result = monitor_db.select(query, args=[user])
|
||||
|
@ -382,6 +388,7 @@ class Users(object):
|
|||
'is_restricted': item['is_restricted'],
|
||||
'do_notify': item['do_notify'],
|
||||
'keep_history': item['keep_history'],
|
||||
'deleted_user': item['deleted_user'],
|
||||
'allow_guest': item['allow_guest']
|
||||
}
|
||||
return user_details
|
||||
|
@ -637,7 +644,8 @@ class Users(object):
|
|||
if user_id:
|
||||
try:
|
||||
monitor_db = database.MonitorDatabase()
|
||||
query = 'SELECT allow_guest, user_token, server_token FROM users WHERE user_id = ?'
|
||||
query = 'SELECT allow_guest, user_token, server_token FROM users ' \
|
||||
'WHERE user_id = ? AND deleted_user = 0'
|
||||
result = monitor_db.select_single(query, args=[user_id])
|
||||
if result:
|
||||
tokens = {'allow_guest': result['allow_guest'],
|
||||
|
|
|
@ -39,7 +39,7 @@ def check_credentials(username, password):
|
|||
return True, u'admin'
|
||||
elif username == plexpy.CONFIG.HTTP_USERNAME and password == plexpy.CONFIG.HTTP_PASSWORD:
|
||||
return True, u'admin'
|
||||
elif user_login(username, password):
|
||||
elif plexpy.CONFIG.ALLOW_GUEST_ACCESS and user_login(username, password):
|
||||
return True, u'guest'
|
||||
else:
|
||||
return False, None
|
||||
|
|
|
@ -671,6 +671,7 @@ class WebInterface(object):
|
|||
custom_thumb = kwargs.get('custom_thumb', '')
|
||||
do_notify = kwargs.get('do_notify', 0)
|
||||
keep_history = kwargs.get('keep_history', 0)
|
||||
allow_guest = kwargs.get('allow_guest', 0)
|
||||
|
||||
user_data = users.Users()
|
||||
if user_id:
|
||||
|
@ -679,7 +680,8 @@ class WebInterface(object):
|
|||
friendly_name=friendly_name,
|
||||
custom_thumb=custom_thumb,
|
||||
do_notify=do_notify,
|
||||
keep_history=keep_history)
|
||||
keep_history=keep_history,
|
||||
allow_guest=allow_guest)
|
||||
status_message = "Successfully updated user."
|
||||
return status_message
|
||||
except:
|
||||
|
@ -1257,6 +1259,7 @@ class WebInterface(object):
|
|||
http_password = ''
|
||||
|
||||
config = {
|
||||
"allow_guest_access": checked(plexpy.CONFIG.ALLOW_GUEST_ACCESS),
|
||||
"http_hash_password": checked(plexpy.CONFIG.HTTP_HASH_PASSWORD),
|
||||
"http_hashed_password": plexpy.CONFIG.HTTP_HASHED_PASSWORD,
|
||||
"http_host": plexpy.CONFIG.HTTP_HOST,
|
||||
|
@ -1384,7 +1387,8 @@ class WebInterface(object):
|
|||
"refresh_libraries_on_startup", "refresh_users_on_startup",
|
||||
"ip_logging_enable", "movie_logging_enable", "tv_logging_enable", "music_logging_enable",
|
||||
"notify_consecutive", "notify_upload_posters", "notify_recently_added", "notify_recently_added_grandparent",
|
||||
"monitor_pms_updates", "monitor_remote_access", "get_file_sizes", "log_blacklist", "http_hash_password"
|
||||
"monitor_pms_updates", "monitor_remote_access", "get_file_sizes", "log_blacklist", "http_hash_password",
|
||||
"allow_guest_access"
|
||||
]
|
||||
for checked_config in checked_configs:
|
||||
if checked_config not in kwargs:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue