mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-07 21:51:14 -07:00
No longer storing plex username and password. Only token.
Redirect to config page if no Plexwatch database set.
This commit is contained in:
parent
c0f487940f
commit
d2c65e6a65
3 changed files with 78 additions and 38 deletions
|
@ -162,15 +162,11 @@
|
||||||
<p class="help-block">Port that Plex Media Server is listening on.</p>
|
<p class="help-block">Port that Plex Media Server is listening on.</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="pms_username">PMS Username</label>
|
<label for="pms_token">PMS Token</label>
|
||||||
<input type="text" id="pms_username" name="pms_username" value="${config['pms_username']}" size="30">
|
<input type="text" id="pms_token" name="pms_token" value="${config['pms_token']}" size="30">
|
||||||
<p class="help-block">Username for Plex.tv authentication. Leave empty if no authentication is required.</p>
|
<p class="help-block">Token for Plex.tv authentication. Leave empty if no authentication is required.</p>
|
||||||
</div>
|
|
||||||
<div class="form-group">
|
|
||||||
<label for="pms_password">PMS Password</label>
|
|
||||||
<input type="password" id="pms_password" name="pms_password" value="${config['pms_password']}" size="30">
|
|
||||||
<p class="help-block">Password for Plex.tv authentication. Leave empty if no authentication is required.</p>
|
|
||||||
</div>
|
</div>
|
||||||
|
<p class="help-block"><a href="#pms-auth-modal" data-toggle="modal">Fetch Token</a></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div class="span4">
|
<div class="span4">
|
||||||
|
@ -325,6 +321,42 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer"></div>
|
<div class="modal-footer"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div id="pms-auth-modal" class="modal hide fade" tabindex="-1" role="dialog"
|
||||||
|
aria-labelledby="ip-info-modal" aria-hidden="true">
|
||||||
|
<div class="modal-header">
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i
|
||||||
|
class="fa fa-remove"></i></button>
|
||||||
|
<h3 id="PMSAuthModal">Fetch Plex.tv Token</h3>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="modal-text">
|
||||||
|
<div>
|
||||||
|
<div class="span6">
|
||||||
|
<span>
|
||||||
|
This will attempt to fetch your token for you. This will not work on Internet Explorer 9 or lower.
|
||||||
|
PlexPy does not store your username and password.
|
||||||
|
</span>
|
||||||
|
<br/><br/>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="pms_username">PMS Username</label>
|
||||||
|
<input type="text" id="pms_username" name="pms_username" size="30">
|
||||||
|
<p class="help-block">Username for Plex.tv authentication.</p>
|
||||||
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="pms_password">PMS Password</label>
|
||||||
|
<input type="password" id="pms_password" name="pms_password" size="30">
|
||||||
|
<p class="help-block">Password for Plex.tv authentication.</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<div class="">
|
||||||
|
<input type="button" id="get-pms-auth-token" class="btn btn-primary" value="Fetch Token">
|
||||||
|
<span id="pms-token-status"></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!--
|
<!--
|
||||||
<div role="tabpanel" class="tab-pane" id="tabs-5">
|
<div role="tabpanel" class="tab-pane" id="tabs-5">
|
||||||
|
@ -683,6 +715,38 @@
|
||||||
<%def name="javascriptIncludes()">
|
<%def name="javascriptIncludes()">
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
|
// Plex.tv auth token fetch
|
||||||
|
$("#get-pms-auth-token").click(function() {
|
||||||
|
$("#pms-token-status").html('<i class="fa fa-refresh fa-spin"></i> Fetching token...');
|
||||||
|
if (($("#pms_username").val() !== '') || ($("#pms_password").val() !== '')) {
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: "https://plex.tv/users/sign_in.xml",
|
||||||
|
dataType: 'xml',
|
||||||
|
async: true,
|
||||||
|
headers: {'Content-Type': 'application/xml; charset=utf-8',
|
||||||
|
'Content-Length': '0',
|
||||||
|
'X-Plex-Device-Name': 'PlexPy',
|
||||||
|
'X-Plex-Product': 'PlexPy',
|
||||||
|
'X-Plex-Version': 'v0.1 dev',
|
||||||
|
'X-Plex-Client-Identifier': 'f0864d3531d75b19fa9204eaea456515e2502017',
|
||||||
|
'Authorization': 'Basic ' + btoa($("#pms_username").val() + ':' + $("#pms_password").val())
|
||||||
|
},
|
||||||
|
error: function(jqXHR, textStatus, errorThrown) {
|
||||||
|
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> Authentation failed!');
|
||||||
|
},
|
||||||
|
success: function (xml) {
|
||||||
|
var authToken = $(xml).find('user').attr('authenticationToken');
|
||||||
|
$("#pms-token-status").html('<i class="fa fa-check"></i> Authentation successful!');
|
||||||
|
$("#pms_token").val(authToken);
|
||||||
|
$('#pms-auth-modal').modal('hide');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$("#pms-token-status").html("You must enter both fields.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function openExtrasDialog() {
|
function openExtrasDialog() {
|
||||||
$("#dialog").dialog({ close: function(){
|
$("#dialog").dialog({ close: function(){
|
||||||
var elem = '<input type="button" data-success="Changes saved successfully">';
|
var elem = '<input type="button" data-success="Changes saved successfully">';
|
||||||
|
|
|
@ -2224,8 +2224,6 @@ input[type="button"].btn-block {
|
||||||
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
|
/* Darken IE7 buttons by default so they stand out more given they won't have borders */
|
||||||
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
filter: progid:DXImageTransform.Microsoft.gradient(enabled = false);
|
||||||
padding: 6px 25px;
|
padding: 6px 25px;
|
||||||
font-size: 18px;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
}
|
||||||
.btn-primary:hover,
|
.btn-primary:hover,
|
||||||
.btn-primary:focus,
|
.btn-primary:focus,
|
||||||
|
|
|
@ -56,7 +56,10 @@ class WebInterface(object):
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def home(self):
|
def home(self):
|
||||||
return serve_template(templatename="index.html", title="Home")
|
if plexpy.CONFIG.PLEXWATCH_DATABASE == '':
|
||||||
|
raise cherrypy.HTTPRedirect("config")
|
||||||
|
else:
|
||||||
|
return serve_template(templatename="index.html", title="Home")
|
||||||
|
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def get_date_formats(self):
|
def get_date_formats(self):
|
||||||
|
@ -202,10 +205,6 @@ class WebInterface(object):
|
||||||
http_password = ' '
|
http_password = ' '
|
||||||
else:
|
else:
|
||||||
http_password = ''
|
http_password = ''
|
||||||
if plexpy.CONFIG.PMS_PASSWORD != '':
|
|
||||||
pms_password = ' '
|
|
||||||
else:
|
|
||||||
pms_password = ''
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
"http_host": plexpy.CONFIG.HTTP_HOST,
|
"http_host": plexpy.CONFIG.HTTP_HOST,
|
||||||
|
@ -273,8 +272,7 @@ class WebInterface(object):
|
||||||
"email_tls": checked(plexpy.CONFIG.EMAIL_TLS),
|
"email_tls": checked(plexpy.CONFIG.EMAIL_TLS),
|
||||||
"pms_ip": plexpy.CONFIG.PMS_IP,
|
"pms_ip": plexpy.CONFIG.PMS_IP,
|
||||||
"pms_port": plexpy.CONFIG.PMS_PORT,
|
"pms_port": plexpy.CONFIG.PMS_PORT,
|
||||||
"pms_username": plexpy.CONFIG.PMS_USERNAME,
|
"pms_token": plexpy.CONFIG.PMS_TOKEN,
|
||||||
"pms_password": pms_password,
|
|
||||||
"plexwatch_database": plexpy.CONFIG.PLEXWATCH_DATABASE,
|
"plexwatch_database": plexpy.CONFIG.PLEXWATCH_DATABASE,
|
||||||
"date_format": plexpy.CONFIG.DATE_FORMAT,
|
"date_format": plexpy.CONFIG.DATE_FORMAT,
|
||||||
"time_format": plexpy.CONFIG.TIME_FORMAT,
|
"time_format": plexpy.CONFIG.TIME_FORMAT,
|
||||||
|
@ -303,29 +301,9 @@ class WebInterface(object):
|
||||||
# checked items should be zero or one. if they were not sent then the item was not checked
|
# checked items should be zero or one. if they were not sent then the item was not checked
|
||||||
kwargs[checked_config] = 0
|
kwargs[checked_config] = 0
|
||||||
|
|
||||||
# Write Plex token to the config
|
# If http password exists in config, do not overwrite when blank value received
|
||||||
if (not plexpy.CONFIG.PMS_TOKEN or plexpy.CONFIG.PMS_TOKEN == '' \
|
|
||||||
or kwargs['pms_username'] != plexpy.CONFIG.PMS_USERNAME) \
|
|
||||||
and (kwargs['pms_username'] != '' or kwargs['pms_password'] != ''):
|
|
||||||
|
|
||||||
plex_tv = plextv.PlexTV(kwargs['pms_username'], kwargs['pms_password'])
|
|
||||||
token = plex_tv.get_token()
|
|
||||||
|
|
||||||
if token:
|
|
||||||
kwargs['pms_token'] = token
|
|
||||||
logger.info('Plex.tv token sucessfully written to config.')
|
|
||||||
else:
|
|
||||||
logger.warn('Unable to write Plex.tv token to config.')
|
|
||||||
|
|
||||||
# Clear Plex token if username or password set to blank
|
|
||||||
if kwargs['pms_username'] == '' or kwargs['pms_password'] == '':
|
|
||||||
kwargs['pms_token'] = ''
|
|
||||||
|
|
||||||
# If passwords exists in config, do not overwrite when blank value received
|
|
||||||
if kwargs['http_password'] == ' ' and plexpy.CONFIG.HTTP_PASSWORD != '':
|
if kwargs['http_password'] == ' ' and plexpy.CONFIG.HTTP_PASSWORD != '':
|
||||||
kwargs['http_password'] = plexpy.CONFIG.HTTP_PASSWORD
|
kwargs['http_password'] = plexpy.CONFIG.HTTP_PASSWORD
|
||||||
if kwargs['pms_password'] == ' ' and plexpy.CONFIG.PMS_PASSWORD != '':
|
|
||||||
kwargs['pms_password'] = plexpy.CONFIG.PMS_PASSWORD
|
|
||||||
|
|
||||||
for plain_config, use_config in [(x[4:], x) for x in kwargs if x.startswith('use_')]:
|
for plain_config, use_config in [(x[4:], x) for x in kwargs if x.startswith('use_')]:
|
||||||
# the use prefix is fairly nice in the html, but does not match the actual config
|
# the use prefix is fairly nice in the html, but does not match the actual config
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue