web-manager 2.1.32 → 2.1.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. package/index.js +87 -33
  2. package/lib/account.js +27 -0
  3. package/package.json +3 -3
package/index.js CHANGED
@@ -169,7 +169,7 @@ function Manager() {
169
169
  this.properties.page.status.eventHandlersSet = true;
170
170
  var This = this;
171
171
  // document.addEventListener('click', function (event) {
172
- This.dom().select('body').on('click', function (event) {
172
+ document.addEventListener('click', function (event) {
173
173
  // console.log('Clicked.... NEW');
174
174
  // This.log('Clicked', event.target);
175
175
  // auth events
@@ -837,26 +837,45 @@ function Manager() {
837
837
  domLib.select(erel).hide().setInnerHTML('');
838
838
  }
839
839
 
840
- function signinButtonDisabled(status) {
840
+ // function signinButtonDisabled(status) {
841
+ // if (status) {
842
+ // domLib.select('.auth-signin-email-btn').setAttribute('disabled', true);
843
+ // } else {
844
+ // domLib.select('.auth-signin-email-btn').removeAttribute('disabled');
845
+ // }
846
+ // }
847
+ // function signupButtonDisabled(status) {
848
+ // if (status) {
849
+ // domLib.select('.auth-signup-email-btn').setAttribute('disabled', true);
850
+ // } else {
851
+ // domLib.select('.auth-signup-email-btn').removeAttribute('disabled');
852
+ // }
853
+ // }
854
+ // function forgotButtonDisabled(status) {
855
+ // if (status) {
856
+ // domLib.select('.auth-forgot-email-btn').setAttribute('disabled', true);
857
+ // } else {
858
+ // domLib.select('.auth-forgot-email-btn').removeAttribute('disabled');
859
+ // }
860
+ // }
861
+
862
+ function setAuthButtonDisabled(button, status) {
863
+ var el = domLib.select('.auth-' + button + '-email-btn');
864
+ var disabled = 'disabled';
841
865
  if (status) {
842
- domLib.select('.auth-signin-email-btn').setAttribute('disabled', true);
866
+ el.setAttribute(disabled, true);
843
867
  } else {
844
- domLib.select('.auth-signin-email-btn').removeAttribute('disabled');
868
+ el.removeAttribute(disabled);
845
869
  }
846
870
  }
847
- function signupButtonDisabled(status) {
848
- if (status) {
849
- domLib.select('.auth-signup-email-btn').setAttribute('disabled', true);
850
- } else {
851
- domLib.select('.auth-signup-email-btn').removeAttribute('disabled');
852
- }
853
- }
854
- function forgotButtonDisabled(status) {
855
- if (status) {
856
- domLib.select('.auth-forgot-email-btn').setAttribute('disabled', true);
857
- } else {
858
- domLib.select('.auth-forgot-email-btn').removeAttribute('disabled');
859
- }
871
+
872
+ function resolveAuthInput(existing, mode, input) {
873
+ var authSelector = '.auth-';
874
+ var inputSelector = authSelector + input + '-input';
875
+ var formSelector = authSelector + mode + '-form ';
876
+ // var temp
877
+
878
+ return existing || domLib.select(formSelector + inputSelector).getValue() || domLib.select(inputSelector).getValue()
860
879
  }
861
880
 
862
881
  return {
@@ -896,13 +915,20 @@ function Manager() {
896
915
  }
897
916
  },
898
917
  signIn: function (method, email, password) {
918
+ var mode = 'signin';
899
919
  method = method || 'email';
900
920
  _preDisplayError();
901
921
  // This.log('Signin attempt: ', method, email, password);
902
922
  if (method === 'email') {
903
- email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
904
- password = password || domLib.select('.auth-password-input').getValue();
905
- signinButtonDisabled(true);
923
+ // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
924
+ email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
925
+ // password = password || domLib.select('.auth-password-input').getValue();
926
+ password = resolveAuthInput(password, mode, 'password');
927
+ // console.log('Signin attempt: ', method, email, password);
928
+
929
+ // signinButtonDisabled(true);
930
+ setAuthButtonDisabled(mode, true);
931
+
906
932
  firebase.auth().signInWithEmailAndPassword(email, password)
907
933
  .then(function(credential) {
908
934
  // _postAuthSubscriptionCheck(This)
@@ -910,11 +936,13 @@ function Manager() {
910
936
  //
911
937
  // })
912
938
  This.properties.page.status.didSignIn = true;
913
- signinButtonDisabled(false);
939
+ // signinButtonDisabled(false);
940
+ setAuthButtonDisabled(mode, false);
914
941
  // This.log('Good signin');
915
942
  })
916
943
  .catch(function(error) {
917
- signinButtonDisabled(false);
944
+ // signinButtonDisabled(false);
945
+ setAuthButtonDisabled(mode, false);
918
946
  _displayError(error.message);
919
947
  // This.log('Error', error.message);
920
948
  });
@@ -927,22 +955,37 @@ function Manager() {
927
955
  }
928
956
  },
929
957
  signUp: function(method, email, password, passwordConfirm) {
958
+ var mode = 'signup';
930
959
  method = method || 'email';
931
960
 
932
961
  _preDisplayError();
933
962
  // This.log('Signup attempt: ', method, email, password, passwordConfirm);
934
- var termEl = domLib.select('.auth-terms-input');
935
- if (termEl.exists() && !termEl.getValue() === true) {
963
+ // var acceptedTerms
964
+ // var termEl = domLib.select('.auth-terms-input');
965
+ // if (termEl.exists() && !termEl.getValue() === true) {
966
+ // _displayError('Please review and accept our terms.');
967
+ // return;
968
+ // }
969
+ var termsSelector = '.auth-terms-input';
970
+ var termSpecificEl = domLib.select('.auth-signup-form ' + termsSelector)
971
+ var termGenericEl = domLib.select(termsSelector)
972
+ if ((termSpecificEl.exists() && !termSpecificEl.getValue() === true) || (termGenericEl.exists() && !termGenericEl.getValue() === true)) {
936
973
  _displayError('Please review and accept our terms.');
937
974
  return;
938
975
  }
976
+
939
977
  if (method === 'email') {
940
- email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
941
- password = password || domLib.select('.auth-password-input').getValue();
942
- passwordConfirm = passwordConfirm || domLib.select('.auth-password-confirm-input').getValue();
978
+ // email = (email || domLib.select('.auth-email-input').getValue()).trim().toLowerCase();
979
+ email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
980
+ // password = password || domLib.select('.auth-password-input').getValue();
981
+ password = resolveAuthInput(password, mode, 'password');
982
+ // passwordConfirm = passwordConfirm || domLib.select('.auth-password-confirm-input').getValue();
983
+ passwordConfirm = resolveAuthInput(passwordConfirm, mode, 'password-confirm');
984
+ // console.log('Signup attempt: ', method, email, password, passwordConfirm);
943
985
 
944
986
  if (password === passwordConfirm) {
945
- signupButtonDisabled(true);
987
+ // signupButtonDisabled(true);
988
+ setAuthButtonDisabled(mode, true);
946
989
  firebase.auth().createUserWithEmailAndPassword(email, password)
947
990
  .then(function(credential) {
948
991
  This.properties.page.status.didSignUp = true;
@@ -950,7 +993,8 @@ function Manager() {
950
993
  // signupButtonDisabled(false);
951
994
  })
952
995
  .catch(function(error) {
953
- signupButtonDisabled(false);
996
+ // signupButtonDisabled(false);
997
+ setAuthButtonDisabled(mode, false);
954
998
  _displayError(error.message);
955
999
  // This.log('error', error.message);
956
1000
  });
@@ -976,17 +1020,24 @@ function Manager() {
976
1020
  },
977
1021
  forgot: function(email) {
978
1022
  // This.log('forgot()');
979
- email = email || domLib.select('.auth-email-input').getValue();
980
- forgotButtonDisabled(true);
1023
+ var mode = 'forgot';
1024
+ // email = email || domLib.select('.auth-email-input').getValue();
1025
+ email = resolveAuthInput(email, mode, 'email').trim().toLowerCase();
1026
+
1027
+ // forgotButtonDisabled(true);
1028
+ setAuthButtonDisabled(mode, true);
981
1029
  _preDisplayError();
1030
+
982
1031
  firebase.auth().sendPasswordResetEmail(email)
983
1032
  .then(function() {
984
- forgotButtonDisabled(false);
1033
+ // forgotButtonDisabled(false);
1034
+ setAuthButtonDisabled(mode, false);
985
1035
  // This.log('forgot success.');
986
1036
  _displayError('A reset link has been sent to you.');
987
1037
  })
988
1038
  .catch(function(error) {
989
- forgotButtonDisabled(false);
1039
+ // forgotButtonDisabled(false);
1040
+ setAuthButtonDisabled(mode, false);
990
1041
  // This.log('forgot failed: ', error);
991
1042
  _displayError(error.message);
992
1043
  });
@@ -1011,6 +1062,9 @@ function Manager() {
1011
1062
  // This.log('subscribe()');
1012
1063
  return new Promise(function(resolve, reject) {
1013
1064
  // var subscribed = !This.notifications().isSubscribed();
1065
+ if (!supported) {
1066
+ return resolve(false)
1067
+ }
1014
1068
  firebase.messaging().getToken({
1015
1069
  serviceWorkerRegistration: This.properties.references.serviceWorker,
1016
1070
  })
package/lib/account.js CHANGED
@@ -202,6 +202,12 @@ Account.prototype._resolveAccount = function (currentUser, account, options) {
202
202
 
203
203
  var defaultPlanId = options.defaultPlanId || 'basic';
204
204
 
205
+ // Resolve auth
206
+ account.auth = account.auth || {};
207
+ account.auth.email = account.auth.email || currentUser.email || null;
208
+ account.auth.uid = account.auth.uid || currentUser.uid || null;
209
+ account.auth.temporary = account.auth.temporary || false;
210
+
205
211
  // Resolve plan
206
212
  account.plan = account.plan || {};
207
213
  account.plan.id = account.plan.id || defaultPlanId;
@@ -254,6 +260,27 @@ Account.prototype._resolveAccount = function (currentUser, account, options) {
254
260
  account.roles.vip = account.roles.vip === true || account.roles.vip === 'true';
255
261
  account.roles.promoExempt = account.roles.promoExempt === true || account.roles.promoExempt === 'true';
256
262
 
263
+ // Resolve affiliate
264
+ account.affiliate = account.affiliate || {};
265
+ account.affiliate.code = account.affiliate.code || 'unknown';
266
+ account.affiliate.referrals = account.affiliate.referrals || [];
267
+ account.affiliate.referrer = account.affiliate.referrer || 'unknown';
268
+
269
+ // Resolve activity
270
+ account.activity = account.activity || {};
271
+ account.activity.lastActivity = account.activity.lastActivity || {};
272
+ account.activity.lastActivity.timestamp = account.activity.lastActivity.timestamp || '1999-01-01T00:00:00Z';
273
+ account.activity.lastActivity.timestampUNIX = account.activity.lastActivity.timestampUNIX || 0;
274
+
275
+ account.activity.created = account.activity.created || {};
276
+ account.activity.created.timestamp = account.activity.created.timestamp || '1999-01-01T00:00:00Z';
277
+ account.activity.created.timestampUNIX = account.activity.created.timestampUNIX || 0;
278
+
279
+ // Api
280
+ account.api = account.api || {};
281
+ account.api.clientId = account.api.clientId || 'unknown';
282
+ account.api.privateKey = account.api.privateKey || 'unknown';
283
+
257
284
  // Set UI elements
258
285
  try {
259
286
  var isDevelopment = utilities.get(self.Manager, 'properties.meta.environment', '') === 'development';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "2.1.32",
3
+ "version": "2.1.36",
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,9 +23,9 @@
23
23
  },
24
24
  "homepage": "https://itwcreativeworks.com",
25
25
  "dependencies": {
26
- "@sentry/browser": "^6.15.0",
26
+ "@sentry/browser": "^6.17.3",
27
27
  "cookieconsent": "^3.1.1",
28
- "firebase": "^8.10.0",
28
+ "firebase": "^8.10.1",
29
29
  "lazysizes": "^5.3.2"
30
30
  }
31
31
  }