web-manager 2.1.29 → 2.1.33
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 +108 -53
- package/package.json +1 -1
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
|
-
|
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
|
-
|
866
|
+
el.setAttribute(disabled, true);
|
843
867
|
} else {
|
844
|
-
|
868
|
+
el.removeAttribute(disabled);
|
845
869
|
}
|
846
870
|
}
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
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
|
-
|
905
|
-
|
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
|
935
|
-
|
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
|
-
|
942
|
-
|
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
|
-
|
980
|
-
|
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
|
});
|
@@ -1220,6 +1271,7 @@ function Manager() {
|
|
1220
1271
|
if (setting.enabled === true) {
|
1221
1272
|
function _post() {
|
1222
1273
|
// This.log('Loaded Firebase.');
|
1274
|
+
// console.log('_post.');
|
1223
1275
|
window.app = firebase.initializeApp(setting.config);
|
1224
1276
|
|
1225
1277
|
Promise.all([
|
@@ -1231,8 +1283,9 @@ function Manager() {
|
|
1231
1283
|
.catch(reject);
|
1232
1284
|
}
|
1233
1285
|
if (setting.load) {
|
1234
|
-
setting.load()
|
1235
|
-
_post
|
1286
|
+
setting.load(This)
|
1287
|
+
.then(_post)
|
1288
|
+
.catch(reject);
|
1236
1289
|
} else {
|
1237
1290
|
import('firebase/app')
|
1238
1291
|
.then(function(mod) {
|
@@ -1241,9 +1294,8 @@ function Manager() {
|
|
1241
1294
|
})
|
1242
1295
|
.catch(reject);
|
1243
1296
|
}
|
1244
|
-
return resolve()
|
1245
1297
|
} else {
|
1246
|
-
|
1298
|
+
resolve();
|
1247
1299
|
}
|
1248
1300
|
});
|
1249
1301
|
}
|
@@ -1257,15 +1309,16 @@ function Manager() {
|
|
1257
1309
|
var setting = options.libraries.firebase_auth;
|
1258
1310
|
if (setting.enabled === true) {
|
1259
1311
|
if (setting.load) {
|
1260
|
-
setting.load()
|
1261
|
-
resolve
|
1312
|
+
setting.load(This)
|
1313
|
+
.then(resolve)
|
1314
|
+
.catch(reject);
|
1262
1315
|
} else {
|
1263
1316
|
import('firebase/auth')
|
1264
1317
|
.then(resolve)
|
1265
1318
|
.catch(reject);
|
1266
1319
|
}
|
1267
1320
|
} else {
|
1268
|
-
|
1321
|
+
resolve();
|
1269
1322
|
}
|
1270
1323
|
|
1271
1324
|
});
|
@@ -1280,15 +1333,16 @@ function Manager() {
|
|
1280
1333
|
var setting = options.libraries.firebase_firestore;
|
1281
1334
|
if (setting.enabled === true) {
|
1282
1335
|
if (setting.load) {
|
1283
|
-
setting.load()
|
1284
|
-
resolve
|
1336
|
+
setting.load(This)
|
1337
|
+
.then(resolve)
|
1338
|
+
.catch(reject);
|
1285
1339
|
} else {
|
1286
1340
|
import('firebase/firestore')
|
1287
1341
|
.then(resolve)
|
1288
1342
|
.catch(reject);
|
1289
1343
|
}
|
1290
1344
|
} else {
|
1291
|
-
|
1345
|
+
resolve();
|
1292
1346
|
}
|
1293
1347
|
});
|
1294
1348
|
}
|
@@ -1301,15 +1355,16 @@ function Manager() {
|
|
1301
1355
|
var setting = options.libraries.firebase_messaging;
|
1302
1356
|
if (setting.enabled === true) {
|
1303
1357
|
if (setting.load) {
|
1304
|
-
setting.load()
|
1305
|
-
resolve
|
1358
|
+
setting.load(This)
|
1359
|
+
.then(resolve)
|
1360
|
+
.catch(reject);
|
1306
1361
|
} else {
|
1307
1362
|
import('firebase/messaging')
|
1308
1363
|
.then(resolve)
|
1309
1364
|
.catch(reject);
|
1310
1365
|
}
|
1311
1366
|
} else {
|
1312
|
-
|
1367
|
+
resolve();
|
1313
1368
|
}
|
1314
1369
|
});
|
1315
1370
|
}
|
@@ -1336,7 +1391,7 @@ function Manager() {
|
|
1336
1391
|
})
|
1337
1392
|
.catch(reject);
|
1338
1393
|
} else {
|
1339
|
-
|
1394
|
+
resolve();
|
1340
1395
|
}
|
1341
1396
|
});
|
1342
1397
|
}
|
@@ -1351,11 +1406,11 @@ function Manager() {
|
|
1351
1406
|
.then(function(mod) {
|
1352
1407
|
window.cookieconsent.initialise(options.libraries.cookieconsent.config);
|
1353
1408
|
// This.log('Loaded Cookieconsent.');
|
1354
|
-
|
1409
|
+
resolve();
|
1355
1410
|
})
|
1356
1411
|
.catch(reject);
|
1357
1412
|
} else {
|
1358
|
-
|
1413
|
+
resolve();
|
1359
1414
|
}
|
1360
1415
|
|
1361
1416
|
});
|
@@ -1379,11 +1434,11 @@ function Manager() {
|
|
1379
1434
|
return reject(e);
|
1380
1435
|
}
|
1381
1436
|
// This.log('Loaded tawk.');
|
1382
|
-
|
1437
|
+
resolve();
|
1383
1438
|
})
|
1384
1439
|
|
1385
1440
|
} else {
|
1386
|
-
|
1441
|
+
resolve();
|
1387
1442
|
}
|
1388
1443
|
});
|
1389
1444
|
}
|
@@ -1402,11 +1457,11 @@ function Manager() {
|
|
1402
1457
|
config.environment = This.properties.meta.environment;
|
1403
1458
|
Sentry.init(config);
|
1404
1459
|
// This.log('Loaded Sentry.');
|
1405
|
-
|
1460
|
+
resolve();
|
1406
1461
|
})
|
1407
1462
|
.catch(reject);
|
1408
1463
|
} else {
|
1409
|
-
|
1464
|
+
resolve();
|
1410
1465
|
}
|
1411
1466
|
});
|
1412
1467
|
}
|
package/package.json
CHANGED