Skip to content

Commit

Permalink
Check for response.data in setToken, lowered polling to 20ms, no long…
Browse files Browse the repository at this point in the history
…er clears html inside popup
  • Loading branch information
sahat committed Jan 12, 2016
1 parent 4ef5c54 commit c787bce
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
36 changes: 15 additions & 21 deletions satellizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex

if (!token && response) {
var tokenRootData = config.tokenRoot && config.tokenRoot.split('.').reduce(function(o, x) { return o[x]; }, response.data);
token = tokenRootData ? tokenRootData[config.tokenName] : response.data[config.tokenName];
token = tokenRootData ? tokenRootData[config.tokenName] : response.data && response.data[config.tokenName];
}

if (!token) {
Expand Down Expand Up @@ -750,29 +750,23 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex
var documentOrigin = document.location.host;
var popupWindowOrigin = Popup.popupWindow.location.host;

if (popupWindowOrigin === documentOrigin) {
if (popupWindowOrigin === documentOrigin && (Popup.popupWindow.location.search || Popup.popupWindow.location.hash)) {
var queryParams = Popup.popupWindow.location.search.substring(1).replace(/\/$/, '');
var hashParams = Popup.popupWindow.location.hash.substring(1).replace(/[\/$]/, '');
var hash = utils.parseQueryString(hashParams);
var qs = utils.parseQueryString(queryParams);

// Clear the popup's contents
Popup.popupWindow.document.removeChild(Popup.popupWindow.document.documentElement);
angular.extend(qs, hash);

if (Popup.popupWindow.location.search || Popup.popupWindow.location.hash) {
var queryParams = Popup.popupWindow.location.search.substring(1).replace(/\/$/, '');
var hashParams = Popup.popupWindow.location.hash.substring(1).replace(/[\/$]/, '');
var hash = utils.parseQueryString(hashParams);
var qs = utils.parseQueryString(queryParams);

angular.extend(qs, hash);

if (qs.error) {
deferred.reject(qs);
} else {
deferred.resolve(qs);
}
if (qs.error) {
deferred.reject(qs);
} else {
deferred.resolve(qs);
}

$interval.cancel(polling);
$interval.cancel(polling);

Popup.popupWindow.close();
}
Popup.popupWindow.close();
}
} catch (error) {
// Ignore DOMException: Blocked a frame with origin from accessing a cross-origin frame.
Expand All @@ -781,7 +775,7 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex
if (!Popup.popupWindow || Popup.popupWindow.closed || Popup.popupWindow.closed === undefined) {
$interval.cancel(polling);
}
}, 40);
}, 20);

return deferred.promise;
};
Expand Down
Loading

0 comments on commit c787bce

Please sign in to comment.