@logto/react 0.1.12 → 0.1.13
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/lib/hooks/index.js +6 -4
- package/package.json +2 -2
package/lib/hooks/index.js
CHANGED
|
@@ -30,7 +30,7 @@ const useErrorHandler = () => {
|
|
|
30
30
|
return { handleError };
|
|
31
31
|
};
|
|
32
32
|
const useHandleSignInCallback = (returnToPageUrl = window.location.origin) => {
|
|
33
|
-
const { logtoClient, isAuthenticated, error
|
|
33
|
+
const { logtoClient, isAuthenticated, error } = (0, react_1.useContext)(context_1.LogtoContext);
|
|
34
34
|
const { isLoading, setLoadingState } = useLoadingState();
|
|
35
35
|
const { handleError } = useErrorHandler();
|
|
36
36
|
const handleSignInCallback = (0, react_1.useCallback)(async (callbackUri) => {
|
|
@@ -40,7 +40,9 @@ const useHandleSignInCallback = (returnToPageUrl = window.location.origin) => {
|
|
|
40
40
|
try {
|
|
41
41
|
setLoadingState(true);
|
|
42
42
|
await logtoClient.handleSignInCallback(callbackUri);
|
|
43
|
-
|
|
43
|
+
// We deliberately do NOT set isAuthenticated to true here, because the app state may change immediately
|
|
44
|
+
// even before navigating to the return page URL, which might cause rendering problems.
|
|
45
|
+
// Moreover, since the location will be redirected, the isAuthenticated state will not matter any more.
|
|
44
46
|
window.location.assign(returnToPageUrl);
|
|
45
47
|
}
|
|
46
48
|
catch (error) {
|
|
@@ -49,7 +51,7 @@ const useHandleSignInCallback = (returnToPageUrl = window.location.origin) => {
|
|
|
49
51
|
finally {
|
|
50
52
|
setLoadingState(false);
|
|
51
53
|
}
|
|
52
|
-
}, [logtoClient, returnToPageUrl,
|
|
54
|
+
}, [logtoClient, returnToPageUrl, setLoadingState, handleError]);
|
|
53
55
|
(0, react_1.useEffect)(() => {
|
|
54
56
|
if (!isAuthenticated && logtoClient?.isSignInRedirected(window.location.href)) {
|
|
55
57
|
void handleSignInCallback(window.location.href);
|
|
@@ -91,7 +93,7 @@ const useLogto = () => {
|
|
|
91
93
|
await logtoClient.signOut(postLogoutRedirectUri);
|
|
92
94
|
// We deliberately do NOT set isAuthenticated to false here, because the app state may change immediately
|
|
93
95
|
// even before navigating to the oidc end session endpoint, which might cause rendering problems.
|
|
94
|
-
//
|
|
96
|
+
// Moreover, since the location will be redirected, the isAuthenticated state will not matter any more.
|
|
95
97
|
}
|
|
96
98
|
catch (error) {
|
|
97
99
|
handleError(error, 'Unexpected error occurred while signing out.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logto/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"exports": "./lib/index.js",
|
|
6
6
|
"typings": "./lib/index.d.ts",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"publishConfig": {
|
|
57
57
|
"access": "public"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "8f8934f949e71573d9e06a8595826fcc8fb426e2"
|
|
60
60
|
}
|