authscape 1.0.276 → 1.0.278
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 +12 -9
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +21 -25
package/index.js
CHANGED
|
@@ -52,7 +52,11 @@ function AuthScapeApp(_ref) {
|
|
|
52
52
|
loadingLogin = _useState8[0],
|
|
53
53
|
setLoadingLogin = _useState8[1];
|
|
54
54
|
var router = (0, _router.useRouter)();
|
|
55
|
+
(0, _react.useEffect)(function () {}, [loadedUser]);
|
|
55
56
|
(0, _react.useEffect)(function () {
|
|
57
|
+
if (!router.isReady) return;
|
|
58
|
+
|
|
59
|
+
// analytics
|
|
56
60
|
if (loadedUser) {
|
|
57
61
|
if (process.env.googleAnalytics4 != null) {
|
|
58
62
|
init(process.env.googleAnalytics4);
|
|
@@ -61,16 +65,15 @@ function AuthScapeApp(_ref) {
|
|
|
61
65
|
localStorage.setItem("ref", router.query.r);
|
|
62
66
|
}
|
|
63
67
|
}
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
|
|
69
|
+
// ensure login is hit
|
|
66
70
|
if (loadedUser && router.isReady && enforceLoggedIn) {
|
|
67
|
-
if (
|
|
71
|
+
if (router.pathname.indexOf("/login") == -1 && router.pathname.indexOf("404") == -1 && router.pathname.indexOf("/logout") == -1 && router.pathname.indexOf("/signin-oidc") == -1 && router.pathname.indexOf("/signout-oidc") == -1) {
|
|
68
72
|
window.location.href = "/login";
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (!router.isReady) return;
|
|
75
|
+
|
|
76
|
+
// sign in validation
|
|
74
77
|
if (router.query.code != null) {
|
|
75
78
|
setLoadingLogin(true);
|
|
76
79
|
signInValidator(router.query.code);
|
|
@@ -78,7 +81,7 @@ function AuthScapeApp(_ref) {
|
|
|
78
81
|
setLoadingLogin(true);
|
|
79
82
|
authService().login();
|
|
80
83
|
}
|
|
81
|
-
}, [router.isReady]);
|
|
84
|
+
}, [loadedUser, router.isReady]);
|
|
82
85
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
|
|
83
86
|
theme: muiTheme
|
|
84
87
|
}, loadingLogin && /*#__PURE__*/_react["default"].createElement(_material.Box, null, "Please wait. Loading..."), !loadingLogin && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(AuthorizationComponent, {
|
|
@@ -90,13 +93,13 @@ function AuthScapeApp(_ref) {
|
|
|
90
93
|
onAuthenticationLoaded(signedInUser);
|
|
91
94
|
}
|
|
92
95
|
}
|
|
93
|
-
},
|
|
96
|
+
}, children == null && /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
|
|
94
97
|
currentUser: currentUser,
|
|
95
98
|
toast: _reactToastify.toast,
|
|
96
99
|
setIsLoading: setIsLoading,
|
|
97
100
|
loadedUser: loadedUser,
|
|
98
101
|
logEvent: logEvent
|
|
99
|
-
})), children != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children))
|
|
102
|
+
})), children != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children)), /*#__PURE__*/_react["default"].createElement(_Backdrop["default"], {
|
|
100
103
|
sx: {
|
|
101
104
|
color: '#fff',
|
|
102
105
|
zIndex: 99999
|
package/package.json
CHANGED
|
@@ -15,6 +15,15 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
|
|
|
15
15
|
const router = useRouter();
|
|
16
16
|
|
|
17
17
|
useEffect(() => {
|
|
18
|
+
|
|
19
|
+
}, [loadedUser]);
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
|
|
24
|
+
if(!router.isReady) return;
|
|
25
|
+
|
|
26
|
+
// analytics
|
|
18
27
|
if (loadedUser)
|
|
19
28
|
{
|
|
20
29
|
if (process.env.googleAnalytics4 != null)
|
|
@@ -27,25 +36,18 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
|
|
|
27
36
|
localStorage.setItem("ref", router.query.r);
|
|
28
37
|
}
|
|
29
38
|
}
|
|
30
|
-
}, [loadedUser]);
|
|
31
39
|
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
|
|
41
|
+
// ensure login is hit
|
|
35
42
|
if (loadedUser && router.isReady && enforceLoggedIn)
|
|
36
43
|
{
|
|
37
|
-
if (
|
|
44
|
+
if (router.pathname.indexOf("/login") == -1 && router.pathname.indexOf("404") == -1 && router.pathname.indexOf("/logout") == -1 && router.pathname.indexOf("/signin-oidc") == -1 && router.pathname.indexOf("/signout-oidc") == -1)
|
|
38
45
|
{
|
|
39
46
|
window.location.href = "/login";
|
|
40
47
|
}
|
|
41
48
|
}
|
|
42
|
-
|
|
43
|
-
}, [loadedUser, router.isReady])
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if(!router.isReady) return;
|
|
48
49
|
|
|
50
|
+
// sign in validation
|
|
49
51
|
if (router.query.code != null)
|
|
50
52
|
{
|
|
51
53
|
setLoadingLogin(true);
|
|
@@ -57,7 +59,9 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
|
|
|
57
59
|
authService().login();
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
|
|
63
|
+
}, [loadedUser, router.isReady])
|
|
64
|
+
|
|
61
65
|
|
|
62
66
|
return (
|
|
63
67
|
<>
|
|
@@ -79,21 +83,13 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
|
|
|
79
83
|
onAuthenticationLoaded(signedInUser);
|
|
80
84
|
}
|
|
81
85
|
}}>
|
|
82
|
-
{
|
|
83
|
-
<
|
|
86
|
+
{children == null &&
|
|
87
|
+
<Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
|
|
84
88
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
<Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
|
|
90
|
-
}
|
|
91
|
-
{children != null &&
|
|
92
|
-
<>
|
|
93
|
-
{children}
|
|
94
|
-
</>
|
|
95
|
-
}
|
|
96
|
-
</>
|
|
89
|
+
{children != null &&
|
|
90
|
+
<>
|
|
91
|
+
{children}
|
|
92
|
+
</>
|
|
97
93
|
}
|
|
98
94
|
</AuthorizationComponent>
|
|
99
95
|
|