@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"with-authentication-required.d.ts","sourceRoot":"","sources":["../src/with-authentication-required.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,EAAE,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAqB,EACnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"with-authentication-required.d.ts","sourceRoot":"","sources":["../src/with-authentication-required.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAa,EAAE,EAAE,MAAM,OAAO,CAAC;AAE5D,OAAqB,EACnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AAkBzB;;GAEG;AACH,MAAM,WAAW,iCAAiC;IAChD;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,CAAC;IACnC;;;;;;;;OAQG;IACH,aAAa,CAAC,EAAE,MAAM,GAAG,CAAC,OAAO,CAAC;IAClC;;;;;;;;OAQG;IACH,sBAAsB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAChD;AAED;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B,kEAErB,iCAAiC,gBAwC3C,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
|
package/package.json
CHANGED
|
@@ -10,6 +10,11 @@ import Auth0Context, {
|
|
|
10
10
|
*/
|
|
11
11
|
const defaultOnRedirecting = (): JSX.Element => <></>;
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* @ignore
|
|
15
|
+
*/
|
|
16
|
+
const defaultOnBeforeAuthentication = async (): Promise<void> => {/* noop */};
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
19
|
* @ignore
|
|
15
20
|
*/
|
|
@@ -48,6 +53,16 @@ export interface WithAuthenticationRequiredOptions {
|
|
|
48
53
|
* Render a message to show that the user is being redirected to the login.
|
|
49
54
|
*/
|
|
50
55
|
onRedirecting?: () => JSX.Element;
|
|
56
|
+
/**
|
|
57
|
+
* ```js
|
|
58
|
+
* withAuthenticationRequired(Profile, {
|
|
59
|
+
* onBeforeAuthentication: () => { analyticsLibrary.track('login_triggered'); }
|
|
60
|
+
* })
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* Allows executing logic before the user is redirected to the login page.
|
|
64
|
+
*/
|
|
65
|
+
onBeforeAuthentication?: () => Promise<void>;
|
|
51
66
|
/**
|
|
52
67
|
* ```js
|
|
53
68
|
* withAuthenticationRequired(Profile, {
|
|
@@ -87,6 +102,7 @@ const withAuthenticationRequired = <P extends object>(
|
|
|
87
102
|
const {
|
|
88
103
|
returnTo = defaultReturnTo,
|
|
89
104
|
onRedirecting = defaultOnRedirecting,
|
|
105
|
+
onBeforeAuthentication = defaultOnBeforeAuthentication,
|
|
90
106
|
loginOptions,
|
|
91
107
|
context = Auth0Context,
|
|
92
108
|
} = options;
|
|
@@ -106,12 +122,14 @@ const withAuthenticationRequired = <P extends object>(
|
|
|
106
122
|
},
|
|
107
123
|
};
|
|
108
124
|
(async (): Promise<void> => {
|
|
125
|
+
await onBeforeAuthentication();
|
|
109
126
|
await loginWithRedirect(opts);
|
|
110
127
|
})();
|
|
111
128
|
}, [
|
|
112
129
|
isLoading,
|
|
113
130
|
isAuthenticated,
|
|
114
131
|
loginWithRedirect,
|
|
132
|
+
onBeforeAuthentication,
|
|
115
133
|
loginOptions,
|
|
116
134
|
returnTo,
|
|
117
135
|
]);
|