Force refresh Plex.tv token in settings

* Removes the old PlexPy device and fetches a new token
This commit is contained in:
JonnyWong16 2016-09-29 21:21:07 -07:00
commit 0b10e68c60
5 changed files with 115 additions and 20 deletions

View file

@ -418,7 +418,7 @@
if ((pms_username !== '') && (pms_password !== '')) {
$.ajax({
type: 'GET',
url: 'get_pms_token',
url: 'get_plexpy_pms_token',
data: {
username: pms_username,
password: pms_password
@ -426,15 +426,17 @@
cache: false,
async: true,
complete: function (xhr, status) {
var authToken = $.parseJSON(xhr.responseText);
if (authToken) {
$("#pms-token-status").html('<i class="fa fa-check"></i> Authentication successful!');
var result = $.parseJSON(xhr.responseText);
var msg = result.message;
if (result.result == 'success') {
var authToken = result.token;
$("#pms-token-status").html('<i class="fa fa-check"></i> ' + msg);
$('#pms-token-status').fadeIn('fast');
$("#pms_token").val(authToken);
authenticated = true;
getServerOptions(authToken)
} else {
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> Invalid username or password.');
$("#pms-token-status").html('<i class="fa fa-exclamation-circle"></i> ' + msg);
}
}
});