Merge pull request #5095 from jaredevantabor/remove-token-from-sockets

removing token from websocket connection url
This commit is contained in:
Wayne Witzel III
2017-02-01 09:27:22 -05:00
committed by GitHub

View File

@@ -5,8 +5,8 @@
*************************************************/ *************************************************/
import ReconnectingWebSocket from 'reconnectingwebsocket'; import ReconnectingWebSocket from 'reconnectingwebsocket';
export default export default
['$rootScope', '$location', '$log','$state', '$q', 'i18n', 'Authorization', ['$rootScope', '$location', '$log','$state', '$q', 'i18n',
function ($rootScope, $location, $log, $state, $q, i18n, Authorization) { function ($rootScope, $location, $log, $state, $q, i18n) {
var needsResubscribing = false, var needsResubscribing = false,
socketPromise = $q.defer(); socketPromise = $q.defer();
return { return {
@@ -14,8 +14,7 @@ export default
var self = this, var self = this,
host = window.location.host, host = window.location.host,
protocol, protocol,
url, url;
token = Authorization.getToken();
if($location.protocol() === 'http'){ if($location.protocol() === 'http'){
protocol = 'ws'; protocol = 'ws';
@@ -26,8 +25,7 @@ export default
url = `${protocol}://${host}/websocket/`; url = `${protocol}://${host}/websocket/`;
if (!$rootScope.sessionTimer || ($rootScope.sessionTimer && !$rootScope.sessionTimer.isExpired())) { if (!$rootScope.sessionTimer || ($rootScope.sessionTimer && !$rootScope.sessionTimer.isExpired())) {
// We have a valid session token, so attempt socket connection
url = `${url}?token=${token}`;
$log.debug('Socket connecting to: ' + url); $log.debug('Socket connecting to: ' + url);
self.socket = new ReconnectingWebSocket(url, null, { self.socket = new ReconnectingWebSocket(url, null, {