Save client id with token

This commit is contained in:
JonnyWong16 2022-01-20 23:11:21 -08:00
parent 654ff7bdb6
commit 8bb83cff64
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
3 changed files with 7 additions and 6 deletions

View file

@ -2746,7 +2746,7 @@ $(document).ready(function() {
$("#pms-token-status").html('<i class="fa fa-refresh fa-spin"></i>&nbsp; Waiting for authentication...').fadeIn('fast');
}
function OAuthSuccessCallback(authToken) {
$.post('save_pms_token', { token: authToken }, function() {
$.post('save_pms_token', { token: authToken, client_id: $('#pms_client_id').val() }, function() {
showMsg('<i class="fa fa-check"></i> Saved new Plex.tv token.', false, true, 5000);
});
$("#pms-token-status").html('<i class="fa fa-check"></i>&nbsp; Authentication successful.').fadeIn('fast');

View file

@ -112,7 +112,7 @@
</p>
</div>
<input type="hidden" id="pms_token_validated" value="0" data-validate="validatePMStoken">
<input type="hidden" name="pms_client_id" id="pms_client_id" value="${config['pms_client_id']}">
<input type="hidden" name="pms_client_id" id="pms_client_id" value="">
<button id="sign-in-plex" class="btn btn-form" type="button">Sign In with Plex</button>
<span style="margin-left: 10px; display: none;" id="pms-token-status"></span>
</div>
@ -556,7 +556,7 @@ $(document).ready(function() {
$("#pms-token-status").html('<i class="fa fa-refresh fa-spin"></i>&nbsp; Waiting for authentication...').fadeIn('fast');
}
function OAuthSuccessCallback(authToken) {
$.post('save_pms_token', { token: authToken }, function () {
$.post('save_pms_token', { token: authToken, client_id: $('#pms_client_id').val() }, function () {
$("#pms_token_validated").val(1);
});
$("#pms-token-status").html('<i class="fa fa-check"></i>&nbsp; Authentication successful.').fadeIn('fast');

View file

@ -207,7 +207,6 @@ class WebInterface(object):
@requireAuth(member_of("admin"))
def welcome(self, **kwargs):
config = {
"pms_client_id": plexpy.CONFIG.PMS_CLIENT_ID,
"pms_identifier": plexpy.CONFIG.PMS_IDENTIFIER,
"pms_ip": plexpy.CONFIG.PMS_IP,
"pms_port": plexpy.CONFIG.PMS_PORT,
@ -228,9 +227,11 @@ class WebInterface(object):
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
def save_pms_token(self, token=None, **kwargs):
def save_pms_token(self, token=None, client_id=None, **kwargs):
if token is not None:
plexpy.CONFIG.PMS_TOKEN = token
if client_id is not None:
plexpy.CONFIG.PMS_CLIENT_ID = client_id
plexpy.CONFIG.write()
@cherrypy.expose