Merge pull request #1031 from geogolem/reverseProxyTraktAuthFix

use href instead of hostname+port
geogolem 8 years ago committed by GitHub
commit ea22f5db79

@ -6,14 +6,15 @@ require('../../../Mixins/TagInput');
require('bootstrap'); require('bootstrap');
require('bootstrap.tagsinput'); require('bootstrap.tagsinput');
var Config = require('../../../Config');
//if ('searchParams' in HTMLAnchorElement.prototype) { //if ('searchParams' in HTMLAnchorElement.prototype) {
// var URLSearchParams = require('url-search-params-polyfill'); // var URLSearchParams = require('url-search-params-polyfill');
//} //}
var URLSearchParams = require('url-search-params'); var URLSearchParams = require('url-search-params');
var q = window.location;
var callback_url = q.protocol+'//'+q.hostname+(q.port ? ':' + q.port : '')+'/settings/netimport';
var view = Marionette.ItemView.extend({ var view = Marionette.ItemView.extend({
template : 'Settings/NetImport/Options/NetImportOptionsViewTemplate', template : 'Settings/NetImport/Options/NetImportOptionsViewTemplate',
events : { events : {
@ -30,12 +31,17 @@ var view = Marionette.ItemView.extend({
var oauth = params.get('access'); var oauth = params.get('access');
var refresh=params.get('refresh'); var refresh=params.get('refresh');
if (oauth && refresh){ if (oauth && refresh){
history.pushState('object', 'title', callback_url); //var callback_url = window.location.href;
history.pushState('object', 'title', (window.location.href).replace(window.location.search, ''));
this.ui.authToken.val(oauth).trigger('change'); this.ui.authToken.val(oauth).trigger('change');
this.ui.refreshToken.val(refresh).trigger('change'); this.ui.refreshToken.val(refresh).trigger('change');
this.ui.tokenExpiry.val(Math.floor(Date.now() / 1000) + 4838400).trigger('change'); // this means the token will expire in 8 weeks (4838400 seconds) //Config.setValue("traktAuthToken", oauth);
//this.model.isSaved = false; //Config.setValue("traktRefreshToken", refresh);
window.alert("Trakt Authentication Complete - Click Save to make the change take effect"); var tokenExpiry = Math.floor(Date.now() / 1000) + 4838400;
this.ui.tokenExpiry.val(tokenExpiry).trigger('change'); // this means the token will expire in 8 weeks (4838400 seconds)
//Config.setValue("traktTokenExpiry",tokenExpiry);
//this.model.isSaved = false;
//window.alert("Trakt Authentication Complete - Click Save to make the change take effect");
} }
if (this.ui.authToken.val() && this.ui.refreshToken.val()){ if (this.ui.authToken.val() && this.ui.refreshToken.val()){
this.ui.resetTokensButton.hide(); this.ui.resetTokensButton.hide();
@ -118,7 +124,7 @@ var view = Marionette.ItemView.extend({
_resetTraktTokens : function() { _resetTraktTokens : function() {
if (window.confirm("Proceed to trakt.tv for authentication?\nYou will then be redirected back here.")){ if (window.confirm("Proceed to trakt.tv for authentication?\nYou will then be redirected back here.")){
window.location='http://radarr.aeonlucid.com/v1/trakt/redirect?target='+callback_url; window.location='http://radarr.aeonlucid.com/v1/trakt/redirect?target='+window.location.href;
//this.ui.resetTokensButton.hide(); //this.ui.resetTokensButton.hide();
} }
}, },

Loading…
Cancel
Save