authscape 1.0.275 → 1.0.276

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 CHANGED
@@ -60,15 +60,15 @@ function AuthScapeApp(_ref) {
60
60
  if (router.query.r != null) {
61
61
  localStorage.setItem("ref", router.query.r);
62
62
  }
63
-
64
- // if (enforceLoggedIn)
65
- // {
66
- // if (currentUser == null ) {
67
- // window.location.href = "/login";
68
- // }
69
- // }
70
63
  }
71
64
  }, [loadedUser]);
65
+ (0, _react.useEffect)(function () {
66
+ if (loadedUser && router.isReady && enforceLoggedIn) {
67
+ if (currentUser == null && 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
+ window.location.href = "/login";
69
+ }
70
+ }
71
+ }, [loadedUser, router.isReady]);
72
72
  (0, _react.useEffect)(function () {
73
73
  if (!router.isReady) return;
74
74
  if (router.query.code != null) {
@@ -90,13 +90,13 @@ function AuthScapeApp(_ref) {
90
90
  onAuthenticationLoaded(signedInUser);
91
91
  }
92
92
  }
93
- }, children == null && /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
93
+ }, enforceLoggedIn == true && currentUser == null && /*#__PURE__*/_react["default"].createElement("div", null, "Please wait. Loading..."), (enforceLoggedIn == true && currentUser != null || !enforceLoggedIn) && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children == null && /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
94
94
  currentUser: currentUser,
95
95
  toast: _reactToastify.toast,
96
96
  setIsLoading: setIsLoading,
97
97
  loadedUser: loadedUser,
98
98
  logEvent: logEvent
99
- })), children != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children)), /*#__PURE__*/_react["default"].createElement(_Backdrop["default"], {
99
+ })), children != null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children))), /*#__PURE__*/_react["default"].createElement(_Backdrop["default"], {
100
100
  sx: {
101
101
  color: '#fff',
102
102
  zIndex: 99999
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.275",
3
+ "version": "1.0.276",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -26,16 +26,22 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
26
26
  {
27
27
  localStorage.setItem("ref", router.query.r);
28
28
  }
29
+ }
30
+ }, [loadedUser]);
31
+
29
32
 
30
- // if (enforceLoggedIn)
31
- // {
32
- // if (currentUser == null ) {
33
- // window.location.href = "/login";
34
- // }
35
- // }
33
+ useEffect(() => {
36
34
 
35
+ if (loadedUser && router.isReady && enforceLoggedIn)
36
+ {
37
+ if (currentUser == null && 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
+ {
39
+ window.location.href = "/login";
40
+ }
37
41
  }
38
- }, [loadedUser]);
42
+
43
+ }, [loadedUser, router.isReady])
44
+
39
45
 
40
46
  useEffect(() => {
41
47
  if(!router.isReady) return;
@@ -73,13 +79,21 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
73
79
  onAuthenticationLoaded(signedInUser);
74
80
  }
75
81
  }}>
76
- {children == null &&
77
- <Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
82
+ {(enforceLoggedIn == true && currentUser == null) &&
83
+ <div>Please wait. Loading...</div>
78
84
  }
79
- {children != null &&
80
- <>
81
- {children}
82
- </>
85
+
86
+ {((enforceLoggedIn == true && currentUser != null) || !enforceLoggedIn) &&
87
+ <>
88
+ {children == null &&
89
+ <Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
90
+ }
91
+ {children != null &&
92
+ <>
93
+ {children}
94
+ </>
95
+ }
96
+ </>
83
97
  }
84
98
  </AuthorizationComponent>
85
99