@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.esm.js
CHANGED
|
@@ -217,7 +217,7 @@ var toAuth0ClientOptions = function (opts) {
|
|
|
217
217
|
deprecateRedirectUri(opts);
|
|
218
218
|
return __assign(__assign({}, opts), { auth0Client: {
|
|
219
219
|
name: 'auth0-react',
|
|
220
|
-
version: '2.0
|
|
220
|
+
version: '2.1.0',
|
|
221
221
|
} });
|
|
222
222
|
};
|
|
223
223
|
/**
|
|
@@ -484,6 +484,12 @@ var withAuth0 = function (Component, context) {
|
|
|
484
484
|
* @ignore
|
|
485
485
|
*/
|
|
486
486
|
var defaultOnRedirecting = function () { return React.createElement(React.Fragment, null); };
|
|
487
|
+
/**
|
|
488
|
+
* @ignore
|
|
489
|
+
*/
|
|
490
|
+
var defaultOnBeforeAuthentication = function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
491
|
+
return [2 /*return*/];
|
|
492
|
+
}); }); };
|
|
487
493
|
/**
|
|
488
494
|
* @ignore
|
|
489
495
|
*/
|
|
@@ -502,8 +508,8 @@ var withAuthenticationRequired = function (Component, options) {
|
|
|
502
508
|
if (options === void 0) { options = {}; }
|
|
503
509
|
return function WithAuthenticationRequired(props) {
|
|
504
510
|
var _this = this;
|
|
505
|
-
var _a = options.returnTo, returnTo = _a === void 0 ? defaultReturnTo : _a, _b = options.onRedirecting, onRedirecting = _b === void 0 ? defaultOnRedirecting : _b, loginOptions = options.loginOptions,
|
|
506
|
-
var
|
|
511
|
+
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;
|
|
512
|
+
var _e = useAuth0(context), isAuthenticated = _e.isAuthenticated, isLoading = _e.isLoading, loginWithRedirect = _e.loginWithRedirect;
|
|
507
513
|
useEffect(function () {
|
|
508
514
|
if (isLoading || isAuthenticated) {
|
|
509
515
|
return;
|
|
@@ -512,8 +518,11 @@ var withAuthenticationRequired = function (Component, options) {
|
|
|
512
518
|
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
513
519
|
return __generator(this, function (_a) {
|
|
514
520
|
switch (_a.label) {
|
|
515
|
-
case 0: return [4 /*yield*/,
|
|
521
|
+
case 0: return [4 /*yield*/, onBeforeAuthentication()];
|
|
516
522
|
case 1:
|
|
523
|
+
_a.sent();
|
|
524
|
+
return [4 /*yield*/, loginWithRedirect(opts)];
|
|
525
|
+
case 2:
|
|
517
526
|
_a.sent();
|
|
518
527
|
return [2 /*return*/];
|
|
519
528
|
}
|
|
@@ -523,6 +532,7 @@ var withAuthenticationRequired = function (Component, options) {
|
|
|
523
532
|
isLoading,
|
|
524
533
|
isAuthenticated,
|
|
525
534
|
loginWithRedirect,
|
|
535
|
+
onBeforeAuthentication,
|
|
526
536
|
loginOptions,
|
|
527
537
|
returnTo,
|
|
528
538
|
]);
|