Skip to content

Commit

Permalink
Improved comparison logic when validating redirectUri vs popup url
Browse files Browse the repository at this point in the history
  • Loading branch information
sahat committed Feb 16, 2016
1 parent b23cc7e commit 2af5fb9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions satellizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,18 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex
Popup.pollPopup = function(redirectUri) {
var deferred = $q.defer();

var redirectUriParser = document.createElement('a');
redirectUriParser.href = redirectUri;

var redirectUriHost = redirectUriParser.protocol + '//' + redirectUriParser.hostname +
(redirectUriParser.port ? ':' + redirectUriParser.port: '');

var polling = $interval(function() {
try {
var popupWindowOrigin = Popup.popupWindow.location.origin;
var popupWindowHost = Popup.popupWindow.location.protocol + '//' + Popup.popupWindow.location.hostname +
(Popup.popupWindow.location.port ? ':' + Popup.popupWindow.location.port: '');

if (popupWindowOrigin === redirectUri && (Popup.popupWindow.location.search || Popup.popupWindow.location.hash)) {
if (popupWindowHost === redirectUriHost && (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);
Expand Down Expand Up @@ -859,7 +866,7 @@ if (typeof module !== 'undefined' && typeof exports !== 'undefined' && module.ex

}
return result;
}
};
})
.factory('SatellizerStorage', ['$window', '$log', 'SatellizerConfig', function($window, $log, config) {

Expand Down
Loading

0 comments on commit 2af5fb9

Please sign in to comment.