web-manager 3.2.38 → 3.2.40
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.
- package/index.js +38 -14
- package/lib/account.js +43 -5
- package/package.json +2 -2
package/index.js
CHANGED
@@ -707,14 +707,14 @@ function Manager() {
|
|
707
707
|
Manager.prototype.auth = function() {
|
708
708
|
var self = this;
|
709
709
|
var firebaseActive = typeof firebase !== 'undefined';
|
710
|
-
var
|
710
|
+
var $error = select('.auth-error-message-element');
|
711
711
|
|
712
712
|
function _displayError(msg) {
|
713
713
|
console.error(msg);
|
714
|
-
|
714
|
+
$error.show().setInnerHTML(msg);
|
715
715
|
}
|
716
716
|
function _preDisplayError() {
|
717
|
-
|
717
|
+
$error.hide().setInnerHTML('');
|
718
718
|
}
|
719
719
|
|
720
720
|
function setAuthButtonDisabled(button, status) {
|
@@ -727,15 +727,33 @@ function Manager() {
|
|
727
727
|
}
|
728
728
|
}
|
729
729
|
|
730
|
-
function
|
731
|
-
var
|
732
|
-
var inputSelector =
|
733
|
-
var formSelector =
|
734
|
-
var
|
730
|
+
function selectAuthInput(mode, input) {
|
731
|
+
var prefix = '.auth-';
|
732
|
+
var inputSelector = prefix + input + '-input';
|
733
|
+
var formSelector = prefix + mode + '-form ';
|
734
|
+
var formInput = select(formSelector + inputSelector);
|
735
|
+
var input = select(inputSelector);
|
736
|
+
|
737
|
+
return formInput.exists() ? formInput : input;
|
738
|
+
}
|
739
|
+
|
740
|
+
function resolveAuthInputValue(existing, mode, input) {
|
741
|
+
var result = existing || selectAuthInput(mode, input).getValue();
|
735
742
|
|
736
743
|
return input === 'email' ? result.trim().toLowerCase() : result;
|
737
744
|
}
|
738
745
|
|
746
|
+
function uxHandler(email, password, passwordConfirm, mode) {
|
747
|
+
if (!email) {
|
748
|
+
selectAuthInput(mode, 'email').get(0).focus();
|
749
|
+
} else {
|
750
|
+
selectAuthInput(mode, 'password').get(0).focus();
|
751
|
+
if (mode === 'signup') {
|
752
|
+
selectAuthInput(mode, 'password-confirm').get(0).focus();
|
753
|
+
}
|
754
|
+
}
|
755
|
+
}
|
756
|
+
|
739
757
|
return {
|
740
758
|
isAuthenticated: function () {
|
741
759
|
return firebaseActive ? !!firebase.auth().currentUser : false;
|
@@ -778,11 +796,14 @@ function Manager() {
|
|
778
796
|
// self.log('Signin attempt: ', method, email, password);
|
779
797
|
if (method === 'email') {
|
780
798
|
// email = (email || select('.auth-email-input').getValue()).trim().toLowerCase();
|
781
|
-
email =
|
799
|
+
email = resolveAuthInputValue(email, mode, 'email');
|
782
800
|
// password = password || select('.auth-password-input').getValue();
|
783
|
-
password =
|
801
|
+
password = resolveAuthInputValue(password, mode, 'password');
|
784
802
|
// console.log('Signin attempt: ', method, email, password);
|
785
803
|
|
804
|
+
// Handler
|
805
|
+
uxHandler(email, password, undefined, mode);
|
806
|
+
|
786
807
|
// signinButtonDisabled(true);
|
787
808
|
setAuthButtonDisabled(mode, true);
|
788
809
|
|
@@ -832,13 +853,16 @@ function Manager() {
|
|
832
853
|
|
833
854
|
if (method === 'email') {
|
834
855
|
// email = (email || select('.auth-email-input').getValue()).trim().toLowerCase();
|
835
|
-
email =
|
856
|
+
email = resolveAuthInputValue(email, mode, 'email');
|
836
857
|
// password = password || select('.auth-password-input').getValue();
|
837
|
-
password =
|
858
|
+
password = resolveAuthInputValue(password, mode, 'password');
|
838
859
|
// passwordConfirm = passwordConfirm || select('.auth-password-confirm-input').getValue();
|
839
|
-
passwordConfirm =
|
860
|
+
passwordConfirm = resolveAuthInputValue(passwordConfirm, mode, 'password-confirm');
|
840
861
|
// console.log('Signup attempt: ', method, email, password, passwordConfirm);
|
841
862
|
|
863
|
+
// Handler
|
864
|
+
uxHandler(email, password, passwordConfirm, mode);
|
865
|
+
|
842
866
|
if (password === passwordConfirm) {
|
843
867
|
// signupButtonDisabled(true);
|
844
868
|
setAuthButtonDisabled(mode, true);
|
@@ -883,7 +907,7 @@ function Manager() {
|
|
883
907
|
// self.log('forgot()');
|
884
908
|
var mode = 'forgot';
|
885
909
|
// email = email || select('.auth-email-input').getValue();
|
886
|
-
email =
|
910
|
+
email = resolveAuthInputValue(email, mode, 'email')
|
887
911
|
|
888
912
|
// forgotButtonDisabled(true);
|
889
913
|
setAuthButtonDisabled(mode, true);
|
package/lib/account.js
CHANGED
@@ -240,6 +240,9 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
240
240
|
console.log('++++++account', JSON.stringify(account, null, 2));
|
241
241
|
console.log('++++++options', JSON.stringify(options, null, 2));
|
242
242
|
|
243
|
+
// @@@DEVELOPER
|
244
|
+
// account.plan = {};
|
245
|
+
|
243
246
|
// Resolve auth
|
244
247
|
account.auth = account.auth || {};
|
245
248
|
account.auth.uid = account.auth.uid || firebaseUser.uid || null;
|
@@ -262,6 +265,17 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
262
265
|
account.plan.trial.expires.timestamp = new Date(account.plan.trial.expires.timestamp || 0).toISOString()
|
263
266
|
account.plan.trial.expires.timestampUNIX = Math.round(new Date(account.plan.trial.expires.timestamp || 0).getTime() / 1000);
|
264
267
|
|
268
|
+
// @@@DEVELOPER
|
269
|
+
// account.plan.id = 'basic';
|
270
|
+
// account.plan.trial = {
|
271
|
+
// activated: false,
|
272
|
+
// expires: {
|
273
|
+
// timestamp: new Date('2024-04-23T00:07:29.183Z').toISOString(),
|
274
|
+
// timestampUNIX: Math.round(new Date('2024-04-23T00:07:29.183Z').getTime() / 1000),
|
275
|
+
// }
|
276
|
+
// }
|
277
|
+
// account.plan.status = 'suspended';
|
278
|
+
|
265
279
|
account.plan.limits = account.plan.limits || {};
|
266
280
|
// account.plan.devices = account.plan.devices || 1;
|
267
281
|
|
@@ -324,6 +338,8 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
324
338
|
account.plan.id = defaultPlanId;
|
325
339
|
}
|
326
340
|
|
341
|
+
var isBasicPlan = account.plan.id === defaultPlanId;
|
342
|
+
|
327
343
|
// Resolve oAuth2
|
328
344
|
account.oauth2 = account.oauth2 || {};
|
329
345
|
// account.oauth2.google = account.oauth2.google || {};
|
@@ -331,7 +347,6 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
331
347
|
|
332
348
|
// Resolve roles
|
333
349
|
account.roles = account.roles || {};
|
334
|
-
// account.roles.betaTester = account.plan.id === defaultPlanId ? false : account.roles.betaTester === true || account.roles.betaTester === 'true';
|
335
350
|
account.roles.betaTester = account.roles.betaTester === true || account.roles.betaTester === 'true';
|
336
351
|
account.roles.developer = account.roles.developer === true || account.roles.developer === 'true';
|
337
352
|
account.roles.admin = account.roles.admin === true || account.roles.admin === 'true';
|
@@ -397,9 +412,9 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
397
412
|
account.personal.gender = account.personal.gender || '';
|
398
413
|
|
399
414
|
account.personal.location = account.personal.location || {};
|
400
|
-
account.personal.location.city = account.personal.location.city || '';
|
401
415
|
account.personal.location.country = account.personal.location.country || '';
|
402
416
|
account.personal.location.region = account.personal.location.region || '';
|
417
|
+
account.personal.location.city = account.personal.location.city || '';
|
403
418
|
|
404
419
|
account.personal.name = account.personal.name || {};
|
405
420
|
account.personal.name.first = account.personal.name.first || '';
|
@@ -418,6 +433,8 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
418
433
|
var billingUpdateBtn = self.dom.select('.auth-billing-update-btn');
|
419
434
|
var billingPlanId = self.dom.select('.auth-billing-plan-id-element');
|
420
435
|
var billingFrequencyEl = self.dom.select('.auth-billing-frequency-element');
|
436
|
+
var billingStatusEl = self.dom.select('.auth-billing-status-element');
|
437
|
+
var billingStatusColorEl = self.dom.select('.auth-billing-status-color-element');
|
421
438
|
var billingStartDateEl = self.dom.select('.auth-billing-start-date-element');
|
422
439
|
var billingExpirationDateEl = self.dom.select('.auth-billing-expiration-date-element');
|
423
440
|
var billingSuspendedMessageEl = self.dom.select('.auth-billing-suspended-message-element');
|
@@ -488,11 +505,32 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
488
505
|
.setInnerHTML('<i class="fas fa-gift mr-1"></i> Your free trial expires in ' + daysTillTrialExpire + ' days');
|
489
506
|
}
|
490
507
|
|
508
|
+
// Change the status to 'failed' if the plan is suspended because room temperature IQ people think 'suspended' means 'cancelled'
|
509
|
+
var visibleStatus = uppercase(account.plan.status === 'suspended' ? 'failed payment' : account.plan.status);
|
510
|
+
// If user is on trial, start date is trial exp date
|
511
|
+
var visibleStartDate = account.plan.trial.activated ? account.plan.trial.expires.timestamp : account.plan.payment.startDate.timestamp;
|
512
|
+
if (isBasicPlan) {
|
513
|
+
// Set as start of this month
|
514
|
+
visibleStartDate = new Date(now.getFullYear(), now.getMonth(), 1).toISOString();
|
515
|
+
}
|
516
|
+
var visibleFrequency = account.plan.payment.frequency === 'unknown' ? 'monthly' : account.plan.payment.frequency;
|
517
|
+
|
491
518
|
// Update billing UI
|
492
519
|
billingPlanId.setInnerHTML(splitDashesAndUppercase(account.plan.id));
|
493
|
-
billingFrequencyEl.setInnerHTML(
|
494
|
-
|
495
|
-
|
520
|
+
billingFrequencyEl.setInnerHTML(visibleFrequency);
|
521
|
+
billingStatusEl.setInnerHTML(visibleStatus);
|
522
|
+
billingStatusColorEl
|
523
|
+
.removeClass('bg-soft-success').removeClass('bg-soft-danger').removeClass('bg-soft-warning')
|
524
|
+
.removeClass('text-success').removeClass('text-danger').removeClass('text-warning')
|
525
|
+
if (account.plan.status === 'active') {
|
526
|
+
billingStatusColorEl.addClass('bg-soft-success').addClass('text-success');
|
527
|
+
} else {
|
528
|
+
billingStatusColorEl.addClass('bg-soft-danger').addClass('text-danger');
|
529
|
+
}
|
530
|
+
billingStartDateEl.setInnerHTML(new Date(visibleStartDate).toLocaleString(undefined, {
|
531
|
+
weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',
|
532
|
+
}));
|
533
|
+
billingExpirationDateEl.setInnerHTML(isBasicPlan && daysTillExpire < 366
|
496
534
|
? '<i class="fas fa-exclamation-triangle mr-1"></i> Expires in ' + daysTillExpire + ' days '
|
497
535
|
: '');
|
498
536
|
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "web-manager",
|
3
|
-
"version": "3.2.
|
3
|
+
"version": "3.2.40",
|
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": {
|
@@ -36,4 +36,4 @@
|
|
36
36
|
"firebase": "^9.23.0",
|
37
37
|
"lazysizes": "^5.3.2"
|
38
38
|
}
|
39
|
-
}
|
39
|
+
}
|