web-manager 3.2.11 → 3.2.15

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,29 +21,4 @@ function AuthPages() {
21
21
  })
22
22
  }
23
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
-
49
24
  module.exports = AuthPages;
package/index.js CHANGED
@@ -580,7 +580,7 @@ function Manager() {
580
580
  return window.location.href = redirect;
581
581
  }
582
582
 
583
- if (pagePathname.match(/\/(signin|signup|forgot)\//)) {
583
+ if (pagePathname.match(/\/(authentication-required|authentication-success|authentication-token|forgot|oauth2|signin|signout|signup)/)) {
584
584
  import('./helpers/auth-pages.js')
585
585
  .then(function(mod) {
586
586
  mod.default()
package/lib/account.js CHANGED
@@ -11,7 +11,9 @@ function Account(init) {
11
11
  self.dom = init.dom || self.Manager.dom();
12
12
  self.utilities = init.utilities || self.Manager.utilities();
13
13
 
14
- if (new URL(window.location.href).pathname.includes('account')) {
14
+ var url = new URL(window.location.href);
15
+
16
+ if (url.pathname.startsWith('/account')) {
15
17
  self.initializeAccountPage();
16
18
  }
17
19
  } catch (e) {
@@ -102,9 +104,10 @@ Account.prototype.resolve = function (account, options) {
102
104
 
103
105
  account = account || {};
104
106
  options = options || {};
107
+ options.fetchNewAccount = typeof options.fetchNewAccount === 'undefined' ? true : options.fetchNewAccount;
105
108
 
106
109
  // If there is no user logged in or we choose not to fetch the account, resolve a default account
107
- if (!currentUser || !currentUser.uid || options.fetchNewAccount === false) {
110
+ if (!currentUser || !currentUser.uid || !options.fetchNewAccount) {
108
111
  return resolve(
109
112
  self.handleAccount(
110
113
  self._resolveAccount(currentUser, account, options)
@@ -273,11 +276,11 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
273
276
  currentURL = new URL(window.location.href);
274
277
  isDevelopment = self.utilities.get(self.Manager, 'properties.meta.environment', '') === 'development';
275
278
 
276
- if (self.utilities.get(isDevelopment)) {
279
+ if (isDevelopment) {
277
280
  currentURL.searchParams
278
281
  .forEach(function(value, key) {
279
282
  var accountValue = self.utilities.get(account, key, undefined)
280
- if (typeof accountValue !== undefined) {
283
+ if (typeof accountValue !== 'undefined') {
281
284
  if (value === 'true') { value = true }
282
285
  if (value === 'false') { value = false }
283
286
 
@@ -297,6 +300,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
297
300
  var difference = (planExpireDate.getTime() - now.getTime()) / (24 * 3600 * 1000);
298
301
  var startDate = new Date(account.plan.payment.startDate.timestamp);
299
302
  var planIsActive = difference > -1 && account.plan.id !== defaultPlanId;
303
+ var planIsSuspended = account.plan.status === 'suspended';
300
304
 
301
305
  if (planIsActive) {
302
306
  account.plan.id = account.plan.id;
@@ -379,7 +383,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
379
383
  // Set UI elements
380
384
  // In a try/catch because this lib is used in node sometimes
381
385
  try {
382
- var cancelURL = isDevelopment ? 'http://localhost:4001/cancel/' : 'https://itwcreativeworks.com/portal/account/manage/';
386
+ var cancelURL = isDevelopment ? 'http://localhost:4001/cancel' : 'https://itwcreativeworks.com/portal/account/manage';
383
387
 
384
388
  var billingSubscribeBtn = self.dom.select('.auth-billing-subscribe-btn');
385
389
  var billingUpdateBtn = self.dom.select('.auth-billing-update-btn');
@@ -387,6 +391,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
387
391
  var billingFrequencyEl = self.dom.select('.auth-billing-frequency-element');
388
392
  var billingStartDateEl = self.dom.select('.auth-billing-start-date-element');
389
393
  var billingExpirationDateEl = self.dom.select('.auth-billing-expiration-date-element');
394
+ var billingSuspendedMessageEl = self.dom.select('.auth-billing-suspended-message-element');
390
395
 
391
396
  var $referralCount = self.dom.select('.auth-referral-count-element');
392
397
  var $referralCode = self.dom.select('.auth-referral-code-element');
@@ -420,18 +425,26 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
420
425
  )
421
426
  authPhoneInput.setInnerHTML(firebaseUser.phoneNumber).setValue(firebaseUser.phoneNumber)
422
427
 
428
+ billingUpdateBtn.setAttribute('hidden', true).setAttribute('href', updateURL.toString());
423
429
  billingSubscribeBtn.setAttribute('hidden', true);
424
- billingUpdateBtn.setAttribute('hidden', true);
430
+ billingSuspendedMessageEl.setAttribute('hidden');
425
431
 
426
- if (planIsActive) {
427
- updateURL.searchParams.set('orderId', account.plan.payment.orderId);
428
- updateURL.searchParams.set('resourceId', account.plan.payment.resourceId);
432
+ updateURL.searchParams.set('orderId', account.plan.payment.orderId);
433
+ updateURL.searchParams.set('resourceId', account.plan.payment.resourceId);
429
434
 
430
- billingUpdateBtn.removeAttribute('hidden').setAttribute('href', updateURL.toString());
435
+ if (planIsActive) {
436
+ billingUpdateBtn.removeAttribute('hidden');
431
437
  } else {
432
438
  billingSubscribeBtn.removeAttribute('hidden');
433
439
  }
434
440
 
441
+ if (planIsSuspended) {
442
+ billingUpdateBtn.removeAttribute('hidden');
443
+ billingSubscribeBtn.setAttribute('hidden', true);
444
+
445
+ billingSuspendedMessageEl.removeAttribute('hidden');
446
+ }
447
+
435
448
  billingPlanId.setInnerHTML(uppercase(account.plan.id));
436
449
  billingFrequencyEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' (billed ' + uppercase(account.plan.payment.frequency) + ')' : '');
437
450
  billingStartDateEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' - Purchased ' + getMonth(startDate) + ' ' + startDate.getDate() + ', ' + startDate.getFullYear() : '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.11",
3
+ "version": "3.2.15",
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": {