@frontegg/react-hooks 6.52.0 → 6.53.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/auth/hooks.js +5 -3
- package/index.js +1 -1
- package/node/auth/hooks.js +5 -3
- package/node/index.js +1 -1
- package/package.json +3 -3
package/auth/hooks.js
CHANGED
|
@@ -78,15 +78,17 @@ export const useAuthUser = () => {
|
|
|
78
78
|
const routes = useAuthRoutes();
|
|
79
79
|
const onRedirectTo = useOnRedirectTo();
|
|
80
80
|
const user = useAuthUserOrNull();
|
|
81
|
+
const isSSR = typeof window === 'undefined';
|
|
82
|
+
const noUser = {};
|
|
81
83
|
|
|
82
|
-
if (user == null) {
|
|
84
|
+
if (user == null && !isSSR) {
|
|
83
85
|
onRedirectTo(routes.loginUrl, {
|
|
84
86
|
refresh: true
|
|
85
87
|
});
|
|
86
|
-
return
|
|
88
|
+
return noUser;
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
return user;
|
|
91
|
+
return user || noUser;
|
|
90
92
|
};
|
|
91
93
|
export const useAuthUserOrNull = () => {
|
|
92
94
|
const {
|
package/index.js
CHANGED
package/node/auth/hooks.js
CHANGED
|
@@ -112,15 +112,17 @@ const useAuthUser = () => {
|
|
|
112
112
|
const routes = useAuthRoutes();
|
|
113
113
|
const onRedirectTo = useOnRedirectTo();
|
|
114
114
|
const user = useAuthUserOrNull();
|
|
115
|
+
const isSSR = typeof window === 'undefined';
|
|
116
|
+
const noUser = {};
|
|
115
117
|
|
|
116
|
-
if (user == null) {
|
|
118
|
+
if (user == null && !isSSR) {
|
|
117
119
|
onRedirectTo(routes.loginUrl, {
|
|
118
120
|
refresh: true
|
|
119
121
|
});
|
|
120
|
-
return
|
|
122
|
+
return noUser;
|
|
121
123
|
}
|
|
122
124
|
|
|
123
|
-
return user;
|
|
125
|
+
return user || noUser;
|
|
124
126
|
};
|
|
125
127
|
|
|
126
128
|
exports.useAuthUser = useAuthUser;
|
package/node/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@frontegg/react-hooks",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.53.0",
|
|
4
4
|
"main": "./node/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Frontegg LTD",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@babel/runtime": "^7.18.6",
|
|
9
|
-
"@frontegg/redux-store": "6.
|
|
10
|
-
"@frontegg/types": "6.
|
|
9
|
+
"@frontegg/redux-store": "6.53.0",
|
|
10
|
+
"@frontegg/types": "6.53.0",
|
|
11
11
|
"@types/react": "*",
|
|
12
12
|
"react-redux": "^7.x"
|
|
13
13
|
},
|