authscape 1.0.422 → 1.0.426
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/index.js +11 -7
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +13 -6
package/index.js
CHANGED
|
@@ -42,6 +42,10 @@ function AuthScapeApp(_ref) {
|
|
|
42
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
43
43
|
frontEndLoadedState = _useState2[0],
|
|
44
44
|
setFrontEndLoadedState = _useState2[1];
|
|
45
|
+
var _useState3 = (0, _react.useState)(null),
|
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
|
+
signedInUserState = _useState4[0],
|
|
48
|
+
setSignedInUserState = _useState4[1];
|
|
45
49
|
var loadingAuth = (0, _react.useRef)(false);
|
|
46
50
|
var frontEndLoaded = (0, _react.useRef)(false);
|
|
47
51
|
var signedInUser = (0, _react.useRef)(null);
|
|
@@ -158,13 +162,8 @@ function AuthScapeApp(_ref) {
|
|
|
158
162
|
case 6:
|
|
159
163
|
setFrontEndLoadedState(true);
|
|
160
164
|
frontEndLoaded.current = true;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
break;
|
|
164
|
-
}
|
|
165
|
-
_context2.next = 11;
|
|
166
|
-
return authService().login();
|
|
167
|
-
case 11:
|
|
165
|
+
setSignedInUserState(signedInUser.current);
|
|
166
|
+
case 9:
|
|
168
167
|
case "end":
|
|
169
168
|
return _context2.stop();
|
|
170
169
|
}
|
|
@@ -181,6 +180,11 @@ function AuthScapeApp(_ref) {
|
|
|
181
180
|
validateUserSignedIn();
|
|
182
181
|
}
|
|
183
182
|
}
|
|
183
|
+
(0, _react.useEffect)(function () {
|
|
184
|
+
if (signedInUserState == null && enforceLoggedIn && pathname != "/signin-oidc" && frontEndLoadedState == true) {
|
|
185
|
+
authService().login();
|
|
186
|
+
}
|
|
187
|
+
}, [signedInUserState, enforceLoggedIn, frontEndLoadedState]);
|
|
184
188
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
|
|
185
189
|
name: "viewport",
|
|
186
190
|
content: "width=device-width, initial-scale=0.86, maximum-scale=5.0, minimum-scale=0.86"
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {useState, useRef} from 'react';
|
|
1
|
+
import React, {useState, useRef, useEffect} from 'react';
|
|
2
2
|
import { ToastContainer, toast } from 'react-toastify';
|
|
3
3
|
import { ThemeProvider } from '@mui/material/styles';
|
|
4
4
|
import Head from "next/head";
|
|
@@ -12,6 +12,8 @@ export function AuthScapeApp ({Component, layout, pageProps, muiTheme = {}, enfo
|
|
|
12
12
|
|
|
13
13
|
const [frontEndLoadedState, setFrontEndLoadedState] = useState(false);
|
|
14
14
|
|
|
15
|
+
const [signedInUserState, setSignedInUserState] = useState(null);
|
|
16
|
+
|
|
15
17
|
const loadingAuth = useRef(false);
|
|
16
18
|
const frontEndLoaded = useRef(false);
|
|
17
19
|
const signedInUser = useRef(null);
|
|
@@ -116,11 +118,7 @@ export function AuthScapeApp ({Component, layout, pageProps, muiTheme = {}, enfo
|
|
|
116
118
|
|
|
117
119
|
setFrontEndLoadedState(true);
|
|
118
120
|
frontEndLoaded.current = true;
|
|
119
|
-
|
|
120
|
-
if (signedInUser.current == null && enforceLoggedIn && pathname != "/signin-oidc")
|
|
121
|
-
{
|
|
122
|
-
await authService().login();
|
|
123
|
-
}
|
|
121
|
+
setSignedInUserState(signedInUser.current);
|
|
124
122
|
}
|
|
125
123
|
|
|
126
124
|
if (queryCode != null)
|
|
@@ -135,6 +133,15 @@ export function AuthScapeApp ({Component, layout, pageProps, muiTheme = {}, enfo
|
|
|
135
133
|
}
|
|
136
134
|
}
|
|
137
135
|
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
|
|
138
|
+
if (signedInUserState == null && enforceLoggedIn && pathname != "/signin-oidc" && frontEndLoadedState == true)
|
|
139
|
+
{
|
|
140
|
+
authService().login();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
}, [signedInUserState, enforceLoggedIn, frontEndLoadedState]);
|
|
144
|
+
|
|
138
145
|
return (
|
|
139
146
|
<>
|
|
140
147
|
<Head>
|