@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.
- package/dist/auth0-react.cjs.js +14 -4
- package/dist/auth0-react.cjs.js.map +1 -1
- package/dist/auth0-react.esm.js +14 -4
- package/dist/auth0-react.esm.js.map +1 -1
- package/dist/auth0-react.js +14 -4
- package/dist/auth0-react.js.map +1 -1
- package/dist/auth0-react.min.js +1 -1
- package/dist/auth0-react.min.js.map +1 -1
- package/dist/with-authentication-required.d.ts +10 -0
- package/dist/with-authentication-required.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/with-authentication-required.tsx +18 -0
package/dist/auth0-react.js
CHANGED
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
deprecateRedirectUri(opts);
|
|
222
222
|
return __assign(__assign({}, opts), { auth0Client: {
|
|
223
223
|
name: 'auth0-react',
|
|
224
|
-
version: '2.0
|
|
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,
|
|
510
|
-
var
|
|
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*/,
|
|
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
|
]);
|