@auth0/auth0-react 2.0.2 → 2.1.0

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.
@@ -221,7 +221,7 @@
221
221
  deprecateRedirectUri(opts);
222
222
  return __assign(__assign({}, opts), { auth0Client: {
223
223
  name: 'auth0-react',
224
- version: '2.0.2',
224
+ version: '2.1.0',
225
225
  } });
226
226
  };
227
227
  /**
@@ -488,6 +488,12 @@
488
488
  * @ignore
489
489
  */
490
490
  var defaultOnRedirecting = function () { return React.createElement(React.Fragment, null); };
491
+ /**
492
+ * @ignore
493
+ */
494
+ var defaultOnBeforeAuthentication = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
495
+ return [2 /*return*/];
496
+ }); }); };
491
497
  /**
492
498
  * @ignore
493
499
  */
@@ -506,8 +512,8 @@
506
512
  if (options === void 0) { options = {}; }
507
513
  return function WithAuthenticationRequired(props) {
508
514
  var _this = this;
509
- var _a = options.returnTo, returnTo = _a === void 0 ? defaultReturnTo : _a, _b = options.onRedirecting, onRedirecting = _b === void 0 ? defaultOnRedirecting : _b, loginOptions = options.loginOptions, _c = options.context, context = _c === void 0 ? Auth0Context : _c;
510
- var _d = useAuth0(context), isAuthenticated = _d.isAuthenticated, isLoading = _d.isLoading, loginWithRedirect = _d.loginWithRedirect;
515
+ var _a = options.returnTo, returnTo = _a === void 0 ? defaultReturnTo : _a, _b = options.onRedirecting, onRedirecting = _b === void 0 ? defaultOnRedirecting : _b, _c = options.onBeforeAuthentication, onBeforeAuthentication = _c === void 0 ? defaultOnBeforeAuthentication : _c, loginOptions = options.loginOptions, _d = options.context, context = _d === void 0 ? Auth0Context : _d;
516
+ var _e = useAuth0(context), isAuthenticated = _e.isAuthenticated, isLoading = _e.isLoading, loginWithRedirect = _e.loginWithRedirect;
511
517
  React.useEffect(function () {
512
518
  if (isLoading || isAuthenticated) {
513
519
  return;
@@ -516,8 +522,11 @@
516
522
  (function () { return __awaiter(_this, void 0, void 0, function () {
517
523
  return __generator(this, function (_a) {
518
524
  switch (_a.label) {
519
- case 0: return [4 /*yield*/, loginWithRedirect(opts)];
525
+ case 0: return [4 /*yield*/, onBeforeAuthentication()];
520
526
  case 1:
527
+ _a.sent();
528
+ return [4 /*yield*/, loginWithRedirect(opts)];
529
+ case 2:
521
530
  _a.sent();
522
531
  return [2 /*return*/];
523
532
  }
@@ -527,6 +536,7 @@
527
536
  isLoading,
528
537
  isAuthenticated,
529
538
  loginWithRedirect,
539
+ onBeforeAuthentication,
530
540
  loginOptions,
531
541
  returnTo,
532
542
  ]);