@asgardeo/auth-react 1.1.19 → 1.1.21
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/main.js +4 -4
- package/dist/src/authenticate.d.ts.map +1 -1
- package/dist/tsconfig.tsbuildinfo +3 -3
- package/package.json +2 -2
- package/src/authenticate.tsx +30 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authenticate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEH,iBAAiB,EAQpB,MAAM,oBAAoB,CAAC;AAE5B,OAAc,EACV,iBAAiB,EAEjB,iBAAiB,EACjB,SAAS,EAOZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAe,MAAM,GAAG,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAcrF,UAAU,0BAA0B;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,
|
|
1
|
+
{"version":3,"file":"authenticate.d.ts","sourceRoot":"","sources":["../../src/authenticate.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAEH,iBAAiB,EAQpB,MAAM,oBAAoB,CAAC;AAE5B,OAAc,EACV,iBAAiB,EAEjB,iBAAiB,EACjB,SAAS,EAOZ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAe,MAAM,GAAG,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAsB,MAAM,UAAU,CAAC;AAcrF,UAAU,0BAA0B;IAChC,MAAM,EAAE,eAAe,CAAC;IACxB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,QAAA,MAAM,YAAY,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,0BAA0B,CAAC,CA6OlF,CAAC;AAEF,QAAA,MAAM,cAAc,QAAO,oBAE1B,CAAC;AAEF,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -422,8 +422,8 @@
|
|
|
422
422
|
"affectsGlobalScope": false
|
|
423
423
|
},
|
|
424
424
|
"../../node_modules/@asgardeo/auth-spa/dist/src/models/client-config.d.ts": {
|
|
425
|
-
"version": "
|
|
426
|
-
"signature": "
|
|
425
|
+
"version": "bc9fddc9ec17071001efd372a75df15fc2afcab1842e17f3b597b14dae961111",
|
|
426
|
+
"signature": "bc9fddc9ec17071001efd372a75df15fc2afcab1842e17f3b597b14dae961111",
|
|
427
427
|
"affectsGlobalScope": false
|
|
428
428
|
},
|
|
429
429
|
"../../node_modules/@asgardeo/auth-spa/dist/src/models/sign-in.d.ts": {
|
|
@@ -621,7 +621,7 @@
|
|
|
621
621
|
"affectsGlobalScope": false
|
|
622
622
|
},
|
|
623
623
|
"../src/authenticate.tsx": {
|
|
624
|
-
"version": "
|
|
624
|
+
"version": "a3632fa1bf637067b6aa5dfd7ab8ad0486e4349dc7d1129055b2e43d179a3d50",
|
|
625
625
|
"signature": "150d2de23192873482689c0b27ce8d8aa18d83441455f5402821f15f64b59133",
|
|
626
626
|
"affectsGlobalScope": false
|
|
627
627
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asgardeo/auth-react",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.21",
|
|
4
4
|
"description": "Asgardeo Auth React SDK for React Applications.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"WSO2",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"author": "WSO2",
|
|
38
38
|
"license": "Apache-2.0",
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@asgardeo/auth-spa": "^0.4.
|
|
40
|
+
"@asgardeo/auth-spa": "^0.4.11"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@babel/cli": "^7.10.5",
|
package/src/authenticate.tsx
CHANGED
|
@@ -141,6 +141,7 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
|
|
|
141
141
|
}
|
|
142
142
|
(async () => {
|
|
143
143
|
setInitialized(await AuthClient.init(config));
|
|
144
|
+
checkIsAuthenticated();
|
|
144
145
|
})();
|
|
145
146
|
|
|
146
147
|
}, [ config ]);
|
|
@@ -238,6 +239,35 @@ const AuthProvider: FunctionComponent<PropsWithChildren<AuthProviderPropsInterfa
|
|
|
238
239
|
|
|
239
240
|
}, [ config ]);
|
|
240
241
|
|
|
242
|
+
/**
|
|
243
|
+
* Check if the user is authenticated and update the state.isAuthenticated value.
|
|
244
|
+
*/
|
|
245
|
+
const checkIsAuthenticated = async () => {
|
|
246
|
+
const isAuthenticatedState = await AuthClient.isAuthenticated();
|
|
247
|
+
|
|
248
|
+
if (isAuthenticatedState) {
|
|
249
|
+
const response = await AuthClient.getBasicUserInfo();
|
|
250
|
+
|
|
251
|
+
if (response) {
|
|
252
|
+
const stateToUpdate ={
|
|
253
|
+
allowedScopes: response.allowedScopes,
|
|
254
|
+
displayName: response.displayName,
|
|
255
|
+
email: response.email,
|
|
256
|
+
isAuthenticated: true,
|
|
257
|
+
isLoading: false,
|
|
258
|
+
isSigningOut: false,
|
|
259
|
+
sub: response.sub,
|
|
260
|
+
username: response.username
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
AuthClient.updateState(stateToUpdate);
|
|
264
|
+
dispatch({ ...state, ...stateToUpdate });
|
|
265
|
+
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
|
|
241
271
|
/**
|
|
242
272
|
* Render state and special case actions
|
|
243
273
|
*/
|