authscape 1.0.420 → 1.0.424
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 +13 -6
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +14 -6
package/index.js
CHANGED
|
@@ -26,6 +26,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
26
26
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
27
27
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
28
28
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
+
// import { authService, apiService, setupOEMProps, OEMStyleSheet } from 'authscape';
|
|
30
|
+
|
|
29
31
|
function AuthScapeApp(_ref) {
|
|
30
32
|
var Component = _ref.Component,
|
|
31
33
|
layout = _ref.layout,
|
|
@@ -40,6 +42,10 @@ function AuthScapeApp(_ref) {
|
|
|
40
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
41
43
|
frontEndLoadedState = _useState2[0],
|
|
42
44
|
setFrontEndLoadedState = _useState2[1];
|
|
45
|
+
var _useState3 = (0, _react.useState)(null),
|
|
46
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
47
|
+
signedInUserState = _useState4[0],
|
|
48
|
+
setSignedInUserState = _useState4[1];
|
|
43
49
|
var loadingAuth = (0, _react.useRef)(false);
|
|
44
50
|
var frontEndLoaded = (0, _react.useRef)(false);
|
|
45
51
|
var signedInUser = (0, _react.useRef)(null);
|
|
@@ -156,12 +162,8 @@ function AuthScapeApp(_ref) {
|
|
|
156
162
|
case 6:
|
|
157
163
|
setFrontEndLoadedState(true);
|
|
158
164
|
frontEndLoaded.current = true;
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// {
|
|
162
|
-
// await authService().login();
|
|
163
|
-
// }
|
|
164
|
-
case 8:
|
|
165
|
+
setSignedInUserState(signedInUser.current);
|
|
166
|
+
case 9:
|
|
165
167
|
case "end":
|
|
166
168
|
return _context2.stop();
|
|
167
169
|
}
|
|
@@ -178,6 +180,11 @@ function AuthScapeApp(_ref) {
|
|
|
178
180
|
validateUserSignedIn();
|
|
179
181
|
}
|
|
180
182
|
}
|
|
183
|
+
(0, _react.useEffect)(function () {
|
|
184
|
+
if (signedInUserState == null && enforceLoggedIn && pathname != "/signin-oidc" && frontEndLoaded.current == true) {
|
|
185
|
+
authService().login();
|
|
186
|
+
}
|
|
187
|
+
}, [signedInUserState, enforceLoggedIn]);
|
|
181
188
|
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
|
|
182
189
|
name: "viewport",
|
|
183
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";
|
|
@@ -6,11 +6,14 @@ import { useSearchParams, usePathname } from 'next/navigation';
|
|
|
6
6
|
import axios from 'axios';
|
|
7
7
|
import querystring from "query-string";
|
|
8
8
|
import { setCookie } from 'nookies'
|
|
9
|
+
// import { authService, apiService, setupOEMProps, OEMStyleSheet } from 'authscape';
|
|
9
10
|
|
|
10
11
|
export function AuthScapeApp ({Component, layout, pageProps, muiTheme = {}, enforceLoggedIn = false, enableAuth = true}) {
|
|
11
12
|
|
|
12
13
|
const [frontEndLoadedState, setFrontEndLoadedState] = useState(false);
|
|
13
14
|
|
|
15
|
+
const [signedInUserState, setSignedInUserState] = useState(null);
|
|
16
|
+
|
|
14
17
|
const loadingAuth = useRef(false);
|
|
15
18
|
const frontEndLoaded = useRef(false);
|
|
16
19
|
const signedInUser = useRef(null);
|
|
@@ -115,11 +118,7 @@ export function AuthScapeApp ({Component, layout, pageProps, muiTheme = {}, enfo
|
|
|
115
118
|
|
|
116
119
|
setFrontEndLoadedState(true);
|
|
117
120
|
frontEndLoaded.current = true;
|
|
118
|
-
|
|
119
|
-
// if (enforceLoggedIn)
|
|
120
|
-
// {
|
|
121
|
-
// await authService().login();
|
|
122
|
-
// }
|
|
121
|
+
setSignedInUserState(signedInUser.current);
|
|
123
122
|
}
|
|
124
123
|
|
|
125
124
|
if (queryCode != null)
|
|
@@ -134,6 +133,15 @@ export function AuthScapeApp ({Component, layout, pageProps, muiTheme = {}, enfo
|
|
|
134
133
|
}
|
|
135
134
|
}
|
|
136
135
|
|
|
136
|
+
useEffect(() => {
|
|
137
|
+
|
|
138
|
+
if (signedInUserState == null && enforceLoggedIn && pathname != "/signin-oidc" && frontEndLoaded.current == true)
|
|
139
|
+
{
|
|
140
|
+
authService().login();
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
}, [signedInUserState, enforceLoggedIn]);
|
|
144
|
+
|
|
137
145
|
return (
|
|
138
146
|
<>
|
|
139
147
|
<Head>
|