dauth-context-react 0.2.1 → 0.2.101

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.
@@ -356,9 +356,11 @@ var initialDauthState = {
356
356
  loginWithRedirect: function loginWithRedirect() {},
357
357
  logout: function logout() {},
358
358
  getAccessToken: function getAccessToken() {
359
- return initialDauthState.getAccessToken() || '';
359
+ return Promise.resolve('');
360
+ },
361
+ updateUser: function updateUser() {
362
+ return Promise.resolve(false);
360
363
  },
361
- updateUser: function updateUser() {},
362
364
  updateUserWithRedirect: function updateUserWithRedirect() {},
363
365
  // Send email verification
364
366
  sendEmailVerificationStatus: {
@@ -368,7 +370,9 @@ var initialDauthState = {
368
370
  },
369
371
  isLoading: false
370
372
  },
371
- sendEmailVerification: function sendEmailVerification() {}
373
+ sendEmailVerification: function sendEmailVerification() {
374
+ return Promise.resolve(false);
375
+ }
372
376
  };
373
377
 
374
378
  var LOGIN = 'LOGIN';
@@ -608,18 +612,18 @@ var refreshAccessTokenAPI = /*#__PURE__*/function () {
608
612
  };
609
613
  }();
610
614
 
611
- var DAUTH_STATE = 'dauth_state';
615
+ var TOKEN_LS = 'dauth_state';
612
616
 
613
617
  function setDauthStateAction(_x) {
614
618
  return _setDauthStateAction.apply(this, arguments);
615
619
  }
616
620
  function _setDauthStateAction() {
617
621
  _setDauthStateAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
618
- var dispatch, dauth_state, domainName, getUserFetch;
622
+ var dispatch, token, domainName, getUserFetch;
619
623
  return _regeneratorRuntime().wrap(function _callee$(_context) {
620
624
  while (1) switch (_context.prev = _context.next) {
621
625
  case 0:
622
- dispatch = _ref.dispatch, dauth_state = _ref.dauth_state, domainName = _ref.domainName;
626
+ dispatch = _ref.dispatch, token = _ref.token, domainName = _ref.domainName;
623
627
  dispatch({
624
628
  type: SET_IS_LOADING,
625
629
  payload: {
@@ -628,7 +632,7 @@ function _setDauthStateAction() {
628
632
  });
629
633
  _context.prev = 2;
630
634
  _context.next = 5;
631
- return getUserAPI(domainName, dauth_state);
635
+ return getUserAPI(domainName, token);
632
636
  case 5:
633
637
  getUserFetch = _context.sent;
634
638
  if (!(getUserFetch.response.status === 200)) {
@@ -644,7 +648,7 @@ function _setDauthStateAction() {
644
648
  }
645
649
  });
646
650
  window.history.replaceState({}, document.title, getUserFetch.data.domain.loginRedirect);
647
- return _context.abrupt("return", localStorage.setItem(DAUTH_STATE, dauth_state));
651
+ return _context.abrupt("return", localStorage.setItem(TOKEN_LS, token));
648
652
  case 12:
649
653
  return _context.abrupt("return", resetUser(dispatch));
650
654
  case 13:
@@ -713,7 +717,7 @@ function _setAutoLoginAction() {
713
717
  isAuthenticated: true
714
718
  }
715
719
  });
716
- localStorage.setItem(DAUTH_STATE, refreshAccessTokenFetch.data.accessToken);
720
+ localStorage.setItem(TOKEN_LS, refreshAccessTokenFetch.data.accessToken);
717
721
  return _context2.abrupt("return");
718
722
  case 16:
719
723
  window.location.replace(getClientBasePath({
@@ -753,108 +757,96 @@ function _setAutoLoginAction() {
753
757
  }));
754
758
  return _setAutoLoginAction.apply(this, arguments);
755
759
  }
756
- function setLogoutAction(_x3) {
757
- return _setLogoutAction.apply(this, arguments);
758
- }
759
- function _setLogoutAction() {
760
- _setLogoutAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
761
- var dispatch;
762
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
763
- while (1) switch (_context3.prev = _context3.next) {
764
- case 0:
765
- dispatch = _ref3.dispatch;
766
- dispatch({
767
- type: SET_IS_LOADING,
768
- payload: {
769
- isLoading: true
770
- }
771
- });
772
- dispatch({
773
- type: LOGIN,
774
- payload: {
775
- user: {
776
- language: window.document.documentElement.getAttribute('lang') || 'es'
777
- },
778
- domain: {},
779
- isAuthenticated: false
780
- }
781
- });
782
- localStorage.removeItem(DAUTH_STATE);
783
- return _context3.abrupt("return", dispatch({
784
- type: SET_IS_LOADING,
785
- payload: {
786
- isLoading: false
787
- }
788
- }));
789
- case 5:
790
- case "end":
791
- return _context3.stop();
792
- }
793
- }, _callee3);
794
- }));
795
- return _setLogoutAction.apply(this, arguments);
760
+ function setLogoutAction(_ref3) {
761
+ var dispatch = _ref3.dispatch;
762
+ dispatch({
763
+ type: SET_IS_LOADING,
764
+ payload: {
765
+ isLoading: true
766
+ }
767
+ });
768
+ dispatch({
769
+ type: LOGIN,
770
+ payload: {
771
+ user: {
772
+ language: window.document.documentElement.getAttribute('lang') || 'es'
773
+ },
774
+ domain: {},
775
+ isAuthenticated: false
776
+ }
777
+ });
778
+ localStorage.removeItem(TOKEN_LS);
779
+ return dispatch({
780
+ type: SET_IS_LOADING,
781
+ payload: {
782
+ isLoading: false
783
+ }
784
+ });
796
785
  }
797
- function setUpdateUserAction(_x4) {
786
+ function setUpdateUserAction(_x3) {
798
787
  return _setUpdateUserAction.apply(this, arguments);
799
788
  }
800
789
  function _setUpdateUserAction() {
801
- _setUpdateUserAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref4) {
790
+ _setUpdateUserAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref4) {
802
791
  var dispatch, domainName, user, token, getUserFetch;
803
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
804
- while (1) switch (_context4.prev = _context4.next) {
792
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
793
+ while (1) switch (_context3.prev = _context3.next) {
805
794
  case 0:
806
795
  dispatch = _ref4.dispatch, domainName = _ref4.domainName, user = _ref4.user, token = _ref4.token;
807
796
  if (user.language) {
808
797
  window.document.documentElement.setAttribute('lang', user.language);
809
798
  }
810
799
  if (token) {
811
- _context4.next = 4;
800
+ _context3.next = 5;
812
801
  break;
813
802
  }
814
- return _context4.abrupt("return", dispatch({
803
+ dispatch({
815
804
  type: UPDATE_USER,
816
805
  payload: user
817
- }));
818
- case 4:
819
- _context4.prev = 4;
820
- _context4.next = 7;
806
+ });
807
+ return _context3.abrupt("return", false);
808
+ case 5:
809
+ _context3.prev = 5;
810
+ _context3.next = 8;
821
811
  return updateUserAPI(domainName, user, token);
822
- case 7:
823
- getUserFetch = _context4.sent;
812
+ case 8:
813
+ getUserFetch = _context3.sent;
824
814
  if (!(getUserFetch.response.status === 200)) {
825
- _context4.next = 12;
815
+ _context3.next = 14;
826
816
  break;
827
817
  }
828
- return _context4.abrupt("return", dispatch({
818
+ dispatch({
829
819
  type: UPDATE_USER,
830
820
  payload: getUserFetch.data.user
831
- }));
832
- case 12:
833
- console.log('Update user error', getUserFetch.data.message);
834
- return _context4.abrupt("return");
821
+ });
822
+ return _context3.abrupt("return", true);
835
823
  case 14:
836
- _context4.next = 19;
837
- break;
824
+ console.log('Update user error', getUserFetch.data.message);
825
+ return _context3.abrupt("return", false);
838
826
  case 16:
839
- _context4.prev = 16;
840
- _context4.t0 = _context4["catch"](4);
841
- console.log('Update user error', _context4.t0);
842
- case 19:
827
+ _context3.next = 22;
828
+ break;
829
+ case 18:
830
+ _context3.prev = 18;
831
+ _context3.t0 = _context3["catch"](5);
832
+ console.log('Update user error', _context3.t0);
833
+ return _context3.abrupt("return", false);
834
+ case 22:
843
835
  case "end":
844
- return _context4.stop();
836
+ return _context3.stop();
845
837
  }
846
- }, _callee4, null, [[4, 16]]);
838
+ }, _callee3, null, [[5, 18]]);
847
839
  }));
848
840
  return _setUpdateUserAction.apply(this, arguments);
849
841
  }
850
- function sendEmailVerificationAction(_x5) {
842
+ function sendEmailVerificationAction(_x4) {
851
843
  return _sendEmailVerificationAction.apply(this, arguments);
852
844
  }
853
845
  function _sendEmailVerificationAction() {
854
- _sendEmailVerificationAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref5) {
846
+ _sendEmailVerificationAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(_ref5) {
855
847
  var dispatch, domainName, token, sendEmailFetch;
856
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
857
- while (1) switch (_context5.prev = _context5.next) {
848
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
849
+ while (1) switch (_context4.prev = _context4.next) {
858
850
  case 0:
859
851
  dispatch = _ref5.dispatch, domainName = _ref5.domainName, token = _ref5.token;
860
852
  dispatch({
@@ -868,13 +860,13 @@ function _sendEmailVerificationAction() {
868
860
  message: 'Sending email verification...'
869
861
  }
870
862
  });
871
- _context5.prev = 3;
872
- _context5.next = 6;
863
+ _context4.prev = 3;
864
+ _context4.next = 6;
873
865
  return sendEmailVerificationAPI(domainName, token);
874
866
  case 6:
875
- sendEmailFetch = _context5.sent;
867
+ sendEmailFetch = _context4.sent;
876
868
  if (!(sendEmailFetch.response.status === 200)) {
877
- _context5.next = 12;
869
+ _context4.next = 13;
878
870
  break;
879
871
  }
880
872
  dispatch({
@@ -884,11 +876,12 @@ function _sendEmailVerificationAction() {
884
876
  message: sendEmailFetch.data.message
885
877
  }
886
878
  });
887
- return _context5.abrupt("return", dispatch({
879
+ dispatch({
888
880
  type: SET_SEND_EMAIL_VERIFICATION_IS_LOADING,
889
881
  payload: false
890
- }));
891
- case 12:
882
+ });
883
+ return _context4.abrupt("return", true);
884
+ case 13:
892
885
  dispatch({
893
886
  type: SET_SEND_EMAIL_VERIFICATION_STATUS,
894
887
  payload: {
@@ -896,16 +889,17 @@ function _sendEmailVerificationAction() {
896
889
  message: sendEmailFetch.data.message
897
890
  }
898
891
  });
899
- return _context5.abrupt("return", dispatch({
892
+ dispatch({
900
893
  type: SET_SEND_EMAIL_VERIFICATION_IS_LOADING,
901
894
  payload: false
902
- }));
903
- case 14:
904
- _context5.next = 20;
905
- break;
895
+ });
896
+ return _context4.abrupt("return", false);
906
897
  case 16:
907
- _context5.prev = 16;
908
- _context5.t0 = _context5["catch"](3);
898
+ _context4.next = 23;
899
+ break;
900
+ case 18:
901
+ _context4.prev = 18;
902
+ _context4.t0 = _context4["catch"](3);
909
903
  dispatch({
910
904
  type: SET_SEND_EMAIL_VERIFICATION_STATUS,
911
905
  payload: {
@@ -913,109 +907,110 @@ function _sendEmailVerificationAction() {
913
907
  message: 'Send email verification fetch error'
914
908
  }
915
909
  });
916
- return _context5.abrupt("return", dispatch({
910
+ dispatch({
917
911
  type: SET_SEND_EMAIL_VERIFICATION_IS_LOADING,
918
912
  payload: false
919
- }));
920
- case 20:
913
+ });
914
+ return _context4.abrupt("return", false);
915
+ case 23:
921
916
  case "end":
922
- return _context5.stop();
917
+ return _context4.stop();
923
918
  }
924
- }, _callee5, null, [[3, 16]]);
919
+ }, _callee4, null, [[3, 18]]);
925
920
  }));
926
921
  return _sendEmailVerificationAction.apply(this, arguments);
927
922
  }
928
- function checkTokenAction(_x6) {
923
+ function checkTokenAction(_x5) {
929
924
  return _checkTokenAction.apply(this, arguments);
930
925
  }
931
926
  function _checkTokenAction() {
932
- _checkTokenAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref6) {
927
+ _checkTokenAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(_ref6) {
933
928
  var dispatch, domainName, sid, token, refreshAccessTokenFetch;
934
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
935
- while (1) switch (_context6.prev = _context6.next) {
929
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
930
+ while (1) switch (_context5.prev = _context5.next) {
936
931
  case 0:
937
932
  dispatch = _ref6.dispatch, domainName = _ref6.domainName, sid = _ref6.sid, token = _ref6.token;
938
- _context6.prev = 1;
939
- _context6.next = 4;
933
+ _context5.prev = 1;
934
+ _context5.next = 4;
940
935
  return refreshAccessTokenAPI(domainName, token);
941
936
  case 4:
942
- refreshAccessTokenFetch = _context6.sent;
937
+ refreshAccessTokenFetch = _context5.sent;
943
938
  if (!(refreshAccessTokenFetch.response.status === 200)) {
944
- _context6.next = 9;
939
+ _context5.next = 9;
945
940
  break;
946
941
  }
947
- return _context6.abrupt("return");
942
+ return _context5.abrupt("return");
948
943
  case 9:
949
944
  window.location.replace(getClientBasePath({
950
945
  domainName: domainName
951
946
  }) + "/" + routes.tenantSignin + "/" + sid);
952
- return _context6.abrupt("return", resetUser(dispatch));
947
+ return _context5.abrupt("return", resetUser(dispatch));
953
948
  case 11:
954
- _context6.next = 17;
949
+ _context5.next = 17;
955
950
  break;
956
951
  case 13:
957
- _context6.prev = 13;
958
- _context6.t0 = _context6["catch"](1);
952
+ _context5.prev = 13;
953
+ _context5.t0 = _context5["catch"](1);
959
954
  resetUser(dispatch);
960
- throw _context6.t0;
955
+ throw _context5.t0;
961
956
  case 17:
962
957
  case "end":
963
- return _context6.stop();
958
+ return _context5.stop();
964
959
  }
965
- }, _callee6, null, [[1, 13]]);
960
+ }, _callee5, null, [[1, 13]]);
966
961
  }));
967
962
  return _checkTokenAction.apply(this, arguments);
968
963
  }
969
- function getAccessTokenAction(_x7) {
964
+ function getAccessTokenAction(_x6) {
970
965
  return _getAccessTokenAction.apply(this, arguments);
971
966
  }
972
967
  ///////////////////////////////////////////
973
968
  //////////////////////////////////////////
974
969
  function _getAccessTokenAction() {
975
- _getAccessTokenAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(_ref7) {
970
+ _getAccessTokenAction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref7) {
976
971
  var dispatch, domainName, token_ls, refreshAccessTokenFetch, _refreshAccessTokenFe;
977
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
978
- while (1) switch (_context7.prev = _context7.next) {
972
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
973
+ while (1) switch (_context6.prev = _context6.next) {
979
974
  case 0:
980
975
  dispatch = _ref7.dispatch, domainName = _ref7.domainName;
981
- token_ls = localStorage.getItem(DAUTH_STATE);
976
+ token_ls = localStorage.getItem(TOKEN_LS);
982
977
  if (token_ls) {
983
- _context7.next = 4;
978
+ _context6.next = 4;
984
979
  break;
985
980
  }
986
- return _context7.abrupt("return");
981
+ return _context6.abrupt("return");
987
982
  case 4:
988
- _context7.prev = 4;
989
- _context7.next = 7;
983
+ _context6.prev = 4;
984
+ _context6.next = 7;
990
985
  return refreshAccessTokenAPI(domainName, token_ls);
991
986
  case 7:
992
- refreshAccessTokenFetch = _context7.sent;
987
+ refreshAccessTokenFetch = _context6.sent;
993
988
  if (!(refreshAccessTokenFetch.response.status === 200)) {
994
- _context7.next = 12;
989
+ _context6.next = 12;
995
990
  break;
996
991
  }
997
- return _context7.abrupt("return", (_refreshAccessTokenFe = refreshAccessTokenFetch.data.accessToken) != null ? _refreshAccessTokenFe : token_ls);
992
+ return _context6.abrupt("return", (_refreshAccessTokenFe = refreshAccessTokenFetch.data.accessToken) != null ? _refreshAccessTokenFe : token_ls);
998
993
  case 12:
999
994
  resetUser(dispatch);
1000
- return _context7.abrupt("return", 'token-not-found');
995
+ return _context6.abrupt("return", 'token-not-found');
1001
996
  case 14:
1002
- _context7.next = 20;
997
+ _context6.next = 20;
1003
998
  break;
1004
999
  case 16:
1005
- _context7.prev = 16;
1006
- _context7.t0 = _context7["catch"](4);
1000
+ _context6.prev = 16;
1001
+ _context6.t0 = _context6["catch"](4);
1007
1002
  resetUser(dispatch);
1008
- throw _context7.t0;
1003
+ throw _context6.t0;
1009
1004
  case 20:
1010
1005
  case "end":
1011
- return _context7.stop();
1006
+ return _context6.stop();
1012
1007
  }
1013
- }, _callee7, null, [[4, 16]]);
1008
+ }, _callee6, null, [[4, 16]]);
1014
1009
  }));
1015
1010
  return _getAccessTokenAction.apply(this, arguments);
1016
1011
  }
1017
1012
  var resetUser = function resetUser(dispatch) {
1018
- localStorage.removeItem(DAUTH_STATE);
1013
+ localStorage.removeItem(TOKEN_LS);
1019
1014
  return dispatch({
1020
1015
  type: LOGIN,
1021
1016
  payload: {
@@ -1037,7 +1032,7 @@ var DauthProvider = function DauthProvider(props) {
1037
1032
  useEffect(function () {
1038
1033
  if (!dauthState.isAuthenticated) return;
1039
1034
  var interval = setInterval(function () {
1040
- var token_ls = localStorage.getItem(DAUTH_STATE);
1035
+ var token_ls = localStorage.getItem(TOKEN_LS);
1041
1036
  if (!token_ls) return;
1042
1037
  checkTokenAction({
1043
1038
  dispatch: dispatch,
@@ -1055,18 +1050,18 @@ var DauthProvider = function DauthProvider(props) {
1055
1050
  var queryString = window.location.search;
1056
1051
  if (!queryString) return;
1057
1052
  var urlParams = new URLSearchParams(queryString);
1058
- var dauth_state = urlParams.get(DAUTH_STATE);
1059
- if (dauth_state && !dauthState.isAuthenticated) {
1053
+ var token_url = urlParams.get(TOKEN_LS);
1054
+ if (token_url && !dauthState.isAuthenticated) {
1060
1055
  setDauthStateAction({
1061
1056
  dispatch: dispatch,
1062
- dauth_state: dauth_state,
1057
+ token: token_url,
1063
1058
  domainName: domainName
1064
1059
  });
1065
1060
  }
1066
1061
  }, []);
1067
1062
  // Auto Login
1068
1063
  useEffect(function () {
1069
- var dauth_state_ls = localStorage.getItem(DAUTH_STATE);
1064
+ var dauth_state_ls = localStorage.getItem(TOKEN_LS);
1070
1065
  if (dauth_state_ls && !dauthState.isAuthenticated) {
1071
1066
  setAutoLoginAction({
1072
1067
  dispatch: dispatch,
@@ -1086,7 +1081,7 @@ var DauthProvider = function DauthProvider(props) {
1086
1081
  dispatch: dispatch
1087
1082
  });
1088
1083
  }, []);
1089
- var _getAccessToken = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1084
+ var getAccessToken = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1090
1085
  var token;
1091
1086
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1092
1087
  while (1) switch (_context.prev = _context.next) {
@@ -1105,59 +1100,85 @@ var DauthProvider = function DauthProvider(props) {
1105
1100
  }
1106
1101
  }, _callee);
1107
1102
  })), []);
1108
- var updateUser = useCallback(function (_ref2) {
1109
- var name = _ref2.name,
1110
- lastname = _ref2.lastname,
1111
- nickname = _ref2.nickname,
1112
- tel_prefix = _ref2.tel_prefix,
1113
- tel_suffix = _ref2.tel_suffix,
1114
- language = _ref2.language,
1115
- avatar = _ref2.avatar;
1116
- var token_ls = localStorage.getItem(DAUTH_STATE);
1117
- var user = {
1118
- name: name,
1119
- lastname: lastname,
1120
- nickname: nickname,
1121
- tel_prefix: tel_prefix,
1122
- tel_suffix: tel_suffix,
1123
- language: language,
1124
- avatar: avatar
1103
+ var updateUser = useCallback( /*#__PURE__*/function () {
1104
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref2) {
1105
+ var name, lastname, nickname, tel_prefix, tel_suffix, language, avatar, token_ls, user;
1106
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
1107
+ while (1) switch (_context2.prev = _context2.next) {
1108
+ case 0:
1109
+ name = _ref2.name, lastname = _ref2.lastname, nickname = _ref2.nickname, tel_prefix = _ref2.tel_prefix, tel_suffix = _ref2.tel_suffix, language = _ref2.language, avatar = _ref2.avatar;
1110
+ token_ls = localStorage.getItem(TOKEN_LS);
1111
+ user = {
1112
+ name: name,
1113
+ lastname: lastname,
1114
+ nickname: nickname,
1115
+ tel_prefix: tel_prefix,
1116
+ tel_suffix: tel_suffix,
1117
+ language: language,
1118
+ avatar: avatar
1119
+ };
1120
+ _context2.next = 5;
1121
+ return setUpdateUserAction({
1122
+ dispatch: dispatch,
1123
+ domainName: domainName,
1124
+ user: user,
1125
+ token: token_ls
1126
+ });
1127
+ case 5:
1128
+ return _context2.abrupt("return", _context2.sent);
1129
+ case 6:
1130
+ case "end":
1131
+ return _context2.stop();
1132
+ }
1133
+ }, _callee2);
1134
+ }));
1135
+ return function (_x) {
1136
+ return _ref3.apply(this, arguments);
1125
1137
  };
1126
- return setUpdateUserAction({
1127
- dispatch: dispatch,
1128
- domainName: domainName,
1129
- user: user,
1130
- token: token_ls
1131
- });
1132
- }, [domainName]);
1138
+ }(), [domainName]);
1133
1139
  var updateUserWithRedirect = useCallback(function () {
1134
- var token_ls = localStorage.getItem(DAUTH_STATE);
1140
+ var token_ls = localStorage.getItem(TOKEN_LS);
1135
1141
  if (!token_ls) return;
1136
1142
  return window.location.replace(getClientBasePath({
1137
1143
  domainName: domainName
1138
- }) + "\n /" + routes.tenantUpdateUser + "\n /" + sid + "\n /" + token_ls);
1144
+ }) + "/" + routes.tenantUpdateUser + "/" + sid + "/" + token_ls);
1139
1145
  }, [domainName, sid]);
1140
- var sendEmailVerification = useCallback(function () {
1141
- var token_ls = localStorage.getItem(DAUTH_STATE);
1142
- if (!token_ls) return;
1143
- return sendEmailVerificationAction({
1144
- dispatch: dispatch,
1145
- domainName: domainName,
1146
- token: token_ls
1147
- });
1148
- }, [domainName]);
1146
+ var sendEmailVerification = useCallback( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
1147
+ var token_ls;
1148
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
1149
+ while (1) switch (_context3.prev = _context3.next) {
1150
+ case 0:
1151
+ token_ls = localStorage.getItem(TOKEN_LS);
1152
+ if (token_ls) {
1153
+ _context3.next = 3;
1154
+ break;
1155
+ }
1156
+ return _context3.abrupt("return", false);
1157
+ case 3:
1158
+ _context3.next = 5;
1159
+ return sendEmailVerificationAction({
1160
+ dispatch: dispatch,
1161
+ domainName: domainName,
1162
+ token: token_ls
1163
+ });
1164
+ case 5:
1165
+ return _context3.abrupt("return", _context3.sent);
1166
+ case 6:
1167
+ case "end":
1168
+ return _context3.stop();
1169
+ }
1170
+ }, _callee3);
1171
+ })), [domainName]);
1149
1172
  var memoProvider = useMemo(function () {
1150
1173
  return _extends({}, dauthState, {
1151
1174
  loginWithRedirect: loginWithRedirect,
1152
1175
  logout: logout,
1153
- getAccessToken: function getAccessToken() {
1154
- return _getAccessToken() || '';
1155
- },
1176
+ getAccessToken: getAccessToken,
1156
1177
  updateUser: updateUser,
1157
1178
  updateUserWithRedirect: updateUserWithRedirect,
1158
1179
  sendEmailVerification: sendEmailVerification
1159
1180
  });
1160
- }, [dauthState, loginWithRedirect, logout, _getAccessToken, updateUser, updateUserWithRedirect, sendEmailVerification]);
1181
+ }, [dauthState, loginWithRedirect, logout, getAccessToken, updateUser, updateUserWithRedirect, sendEmailVerification]);
1161
1182
  return React.createElement(DauthContext.Provider, {
1162
1183
  value: memoProvider
1163
1184
  }, children);