web-manager 3.2.38 → 3.2.39

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.
Files changed (3) hide show
  1. package/index.js +38 -14
  2. package/lib/account.js +1 -1
  3. package/package.json +1 -1
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 erel = '.auth-error-message-element';
710
+ var $error = select('.auth-error-message-element');
711
711
 
712
712
  function _displayError(msg) {
713
713
  console.error(msg);
714
- select(erel).show().setInnerHTML(msg);
714
+ $error.show().setInnerHTML(msg);
715
715
  }
716
716
  function _preDisplayError() {
717
- select(erel).hide().setInnerHTML('');
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 resolveAuthInput(existing, mode, input) {
731
- var authSelector = '.auth-';
732
- var inputSelector = authSelector + input + '-input';
733
- var formSelector = authSelector + mode + '-form ';
734
- var result = existing || select(formSelector + inputSelector).getValue() || select(inputSelector).getValue();
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 = resolveAuthInput(email, mode, 'email');
799
+ email = resolveAuthInputValue(email, mode, 'email');
782
800
  // password = password || select('.auth-password-input').getValue();
783
- password = resolveAuthInput(password, mode, '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 = resolveAuthInput(email, mode, 'email');
856
+ email = resolveAuthInputValue(email, mode, 'email');
836
857
  // password = password || select('.auth-password-input').getValue();
837
- password = resolveAuthInput(password, mode, 'password');
858
+ password = resolveAuthInputValue(password, mode, 'password');
838
859
  // passwordConfirm = passwordConfirm || select('.auth-password-confirm-input').getValue();
839
- passwordConfirm = resolveAuthInput(passwordConfirm, mode, 'password-confirm');
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 = resolveAuthInput(email, mode, 'email')
910
+ email = resolveAuthInputValue(email, mode, 'email')
887
911
 
888
912
  // forgotButtonDisabled(true);
889
913
  setAuthButtonDisabled(mode, true);
package/lib/account.js CHANGED
@@ -397,9 +397,9 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
397
397
  account.personal.gender = account.personal.gender || '';
398
398
 
399
399
  account.personal.location = account.personal.location || {};
400
- account.personal.location.city = account.personal.location.city || '';
401
400
  account.personal.location.country = account.personal.location.country || '';
402
401
  account.personal.location.region = account.personal.location.region || '';
402
+ account.personal.location.city = account.personal.location.city || '';
403
403
 
404
404
  account.personal.name = account.personal.name || {};
405
405
  account.personal.name.first = account.personal.name.first || '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.38",
3
+ "version": "3.2.39",
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": {