web-manager 3.0.4 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/index.js +26 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -287,10 +287,12 @@ function Manager() {
287
287
  }
288
288
  }
289
289
 
290
+
291
+
290
292
  function _authHandle_in_normal(This, user) {
291
293
  var domLib = This.dom();
292
294
  var returnUrl = This.properties.page.queryString.get('auth_redirect');
293
- if (returnUrl) {
295
+ if (returnUrl && This.isValidRedirectUrl(returnUrl)) {
294
296
  window.location.href = decodeURIComponent(returnUrl);
295
297
  return;
296
298
  }
@@ -624,11 +626,13 @@ function Manager() {
624
626
  This.properties.page.queryString = new URLSearchParams(window.location.search);
625
627
  var pageQueryString = This.properties.page.queryString
626
628
  var pagePathname = window.location.pathname;
627
- if (pageQueryString.get('aff')) {
628
- This.storage().set('auth.affiliateCode', pageQueryString.get('aff'));
629
+ var qsAff = pageQueryString.get('aff');
630
+ if (qsAff) {
631
+ This.storage().set('auth.affiliateCode', qsAff);
629
632
  }
630
- if (pageQueryString.get('redirect')) {
631
- window.location.href = decodeURIComponent(pageQueryString.get('redirect'));
633
+ var qsRedirect = pageQueryString.get('redirect');
634
+ if (qsRedirect && This.isValidRedirectUrl(qsRedirect)) {
635
+ window.location.href = decodeURIComponent(qsRedirect);
632
636
  return;
633
637
  }
634
638
  var authRegex = /\/(signin|signup|forgot)\//;
@@ -990,14 +994,19 @@ function Manager() {
990
994
  signOut: function() {
991
995
  // This.log('signOut()');
992
996
  // var This = this;
993
- firebase.auth().signOut()
994
- .then(function() {
995
- // This.log('signOut success.');
996
- })
997
+ return firebase.auth().signOut()
997
998
  .catch(function(e) {
998
999
  console.error(e);
999
1000
  // This.log('signOut failed: ', error);
1000
1001
  });
1002
+ // return firebase.auth().signOut()
1003
+ // .then(function() {
1004
+ // // This.log('signOut success.');
1005
+ // })
1006
+ // .catch(function(e) {
1007
+ // // console.error(e);
1008
+ // // This.log('signOut failed: ', error);
1009
+ // });
1001
1010
  },
1002
1011
  forgot: function(email) {
1003
1012
  // This.log('forgot()');
@@ -1609,7 +1618,7 @@ function Manager() {
1609
1618
  // }
1610
1619
  // }
1611
1620
  // }
1612
- Manager.prototype.performance = function() {
1621
+ Manager.prototype.performance = function () {
1613
1622
  return {
1614
1623
  mark: function(mark) {
1615
1624
  try {
@@ -1620,6 +1629,13 @@ function Manager() {
1620
1629
  }
1621
1630
  }
1622
1631
 
1632
+ Manager.prototype.isValidRedirectUrl = function (url) {
1633
+ var returnUrlObject = new URL(decodeURIComponent(url));
1634
+ var currentUrlObject = new URL(window.location.href);
1635
+ return returnUrlObject.host === currentUrlObject.host
1636
+ || returnUrlObject.protocol === this.properties.global.app + ':'
1637
+ }
1638
+
1623
1639
  // Manager.prototype.performance = function() {
1624
1640
  // var This = this;
1625
1641
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.0.4",
3
+ "version": "3.0.7",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {