web-manager 3.0.5 → 3.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,26 +5,45 @@ var dom;
5
5
  function AuthPages() {
6
6
  var self = this;
7
7
  dom = window.Manager.dom();
8
- var authRegex = /\/(signin|signup|forgot)/;
9
8
  var pageQueryString = window.Manager.properties.page.queryString;
10
- var pageAuthRedirect = pageQueryString.get('auth_redirect')
11
9
 
12
- if (pageAuthRedirect) {
13
- dom.select('a').each(function (el) {
14
- var href = el.getAttribute('href');
15
- if (href && href.match(authRegex)) {
16
- try {
17
- var newURL = new URL(href);
18
- if (newURL.pathname.match(authRegex)) {
19
- newURL.searchParams.set('auth_redirect', pageAuthRedirect)
20
- el.setAttribute('href', newURL.toString())
21
- }
22
- } catch (e) {
23
- // console.warn('Failed to set auth URL', e);
24
- }
25
- }
26
- })
27
- }
10
+ dom.select('a[href*=signin], a[href*=signup], a[href*=forgot]').each(function (el) {
11
+ var href = el.getAttribute('href');
12
+ try {
13
+ var newURL = new URL(href);
14
+ pageQueryString.forEach(function(value, key) {
15
+ newURL.searchParams.set(key, value)
16
+ })
17
+ el.setAttribute('href', newURL.toString())
18
+ } catch (e) {
19
+ console.warn('Failed to set auth URL', e);
20
+ }
21
+ })
28
22
  }
29
23
 
24
+ // function AuthPages() {
25
+ // var self = this;
26
+ // dom = window.Manager.dom();
27
+ // var authRegex = /\/(signin|signup|forgot)/;
28
+ // var pageQueryString = window.Manager.properties.page.queryString;
29
+ // var pageAuthRedirect = pageQueryString.get('auth_redirect')
30
+ //
31
+ // if (pageAuthRedirect) {
32
+ // dom.select('a').each(function (el) {
33
+ // var href = el.getAttribute('href');
34
+ // if (href && href.match(authRegex)) {
35
+ // try {
36
+ // var newURL = new URL(href);
37
+ // if (newURL.pathname.match(authRegex)) {
38
+ // newURL.searchParams.set('auth_redirect', pageAuthRedirect)
39
+ // el.setAttribute('href', newURL.toString())
40
+ // }
41
+ // } catch (e) {
42
+ // // console.warn('Failed to set auth URL', e);
43
+ // }
44
+ // }
45
+ // })
46
+ // }
47
+ // }
48
+
30
49
  module.exports = AuthPages;
package/index.js CHANGED
@@ -287,17 +287,12 @@ function Manager() {
287
287
  }
288
288
  }
289
289
 
290
- function _isValidRedirectUrl(This, url) {
291
- var returnUrlObject = new URL(decodeURIComponent(url));
292
- var currentUrlObject = new URL(window.location.href);
293
- return returnUrlObject.host === currentUrlObject.host
294
- || returnUrlObject.protocol === This.properties.global.app + ':'
295
- }
290
+
296
291
 
297
292
  function _authHandle_in_normal(This, user) {
298
293
  var domLib = This.dom();
299
294
  var returnUrl = This.properties.page.queryString.get('auth_redirect');
300
- if (returnUrl && _isValidRedirectUrl(This, returnUrl)) {
295
+ if (returnUrl && This.isValidRedirectUrl(returnUrl)) {
301
296
  window.location.href = decodeURIComponent(returnUrl);
302
297
  return;
303
298
  }
@@ -636,7 +631,7 @@ function Manager() {
636
631
  This.storage().set('auth.affiliateCode', qsAff);
637
632
  }
638
633
  var qsRedirect = pageQueryString.get('redirect');
639
- if (qsRedirect && _isValidRedirectUrl(This, qsRedirect)) {
634
+ if (qsRedirect && This.isValidRedirectUrl(qsRedirect)) {
640
635
  window.location.href = decodeURIComponent(qsRedirect);
641
636
  return;
642
637
  }
@@ -821,6 +816,7 @@ function Manager() {
821
816
  var domLib = This.dom();
822
817
 
823
818
  function _displayError(msg) {
819
+ console.error(msg);
824
820
  domLib.select(erel).show().setInnerHTML(msg);
825
821
  }
826
822
  function _preDisplayError() {
@@ -863,9 +859,9 @@ function Manager() {
863
859
  var authSelector = '.auth-';
864
860
  var inputSelector = authSelector + input + '-input';
865
861
  var formSelector = authSelector + mode + '-form ';
866
- // var temp
862
+ var result = existing || domLib.select(formSelector + inputSelector).getValue() || domLib.select(inputSelector).getValue();
867
863
 
868
- return existing || domLib.select(formSelector + inputSelector).getValue() || domLib.select(inputSelector).getValue()
864
+ return input === 'email' ? result.trim().toLowerCase() : result;
869
865
  }
870
866
 
871
867
  return {
@@ -893,7 +889,6 @@ function Manager() {
893
889
  firebase.auth()
894
890
  .getRedirectResult()
895
891
  .catch(function (error) {
896
- console.error(error);
897
892
  _displayError(error.message);
898
893
  });
899
894
  }
@@ -911,7 +906,7 @@ function Manager() {
911
906
  // This.log('Signin attempt: ', method, email, password);
912
907
  if (method === 'email') {
913
908
  // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
914
- email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
909
+ email = resolveAuthInput(email, mode, 'email');
915
910
  // password = password || domLib.select('.auth-password-input').getValue();
916
911
  password = resolveAuthInput(password, mode, 'password');
917
912
  // console.log('Signin attempt: ', method, email, password);
@@ -939,7 +934,6 @@ function Manager() {
939
934
  } else {
940
935
  firebase.auth().signInWithRedirect(new firebase.auth.OAuthProvider(method))
941
936
  .catch(function (e) {
942
- console.error(e);
943
937
  _displayError(e);
944
938
  })
945
939
  }
@@ -966,7 +960,7 @@ function Manager() {
966
960
 
967
961
  if (method === 'email') {
968
962
  // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
969
- email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
963
+ email = resolveAuthInput(email, mode, 'email');
970
964
  // password = password || domLib.select('.auth-password-input').getValue();
971
965
  password = resolveAuthInput(password, mode, 'password');
972
966
  // passwordConfirm = passwordConfirm || domLib.select('.auth-password-confirm-input').getValue();
@@ -999,20 +993,25 @@ function Manager() {
999
993
  signOut: function() {
1000
994
  // This.log('signOut()');
1001
995
  // var This = this;
1002
- firebase.auth().signOut()
1003
- .then(function() {
1004
- // This.log('signOut success.');
1005
- })
996
+ return firebase.auth().signOut()
1006
997
  .catch(function(e) {
1007
998
  console.error(e);
1008
999
  // This.log('signOut failed: ', error);
1009
1000
  });
1001
+ // return firebase.auth().signOut()
1002
+ // .then(function() {
1003
+ // // This.log('signOut success.');
1004
+ // })
1005
+ // .catch(function(e) {
1006
+ // // console.error(e);
1007
+ // // This.log('signOut failed: ', error);
1008
+ // });
1010
1009
  },
1011
1010
  forgot: function(email) {
1012
1011
  // This.log('forgot()');
1013
1012
  var mode = 'forgot';
1014
1013
  // email = email || domLib.select('.auth-email-input').getValue();
1015
- email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
1014
+ email = resolveAuthInput(email, mode, 'email')
1016
1015
 
1017
1016
  // forgotButtonDisabled(true);
1018
1017
  setAuthButtonDisabled(mode, true);
@@ -1618,7 +1617,7 @@ function Manager() {
1618
1617
  // }
1619
1618
  // }
1620
1619
  // }
1621
- Manager.prototype.performance = function() {
1620
+ Manager.prototype.performance = function () {
1622
1621
  return {
1623
1622
  mark: function(mark) {
1624
1623
  try {
@@ -1629,6 +1628,13 @@ function Manager() {
1629
1628
  }
1630
1629
  }
1631
1630
 
1631
+ Manager.prototype.isValidRedirectUrl = function (url) {
1632
+ var returnUrlObject = new URL(decodeURIComponent(url));
1633
+ var currentUrlObject = new URL(window.location.href);
1634
+ return returnUrlObject.host === currentUrlObject.host
1635
+ || returnUrlObject.protocol === this.properties.global.app + ':'
1636
+ }
1637
+
1632
1638
  // Manager.prototype.performance = function() {
1633
1639
  // var This = this;
1634
1640
  //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.0.5",
3
+ "version": "3.0.8",
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": {
@@ -23,7 +23,7 @@
23
23
  },
24
24
  "homepage": "https://itwcreativeworks.com",
25
25
  "dependencies": {
26
- "@sentry/browser": "^6.17.3",
26
+ "@sentry/browser": "^6.19.7",
27
27
  "cookieconsent": "^3.1.1",
28
28
  "firebase": "^8.10.1",
29
29
  "lazysizes": "^5.3.2"