authscape 1.0.188 → 1.0.192

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
@@ -26,7 +26,7 @@ function AuthScapeApp(_ref) {
26
26
  var Component = _ref.Component,
27
27
  pageProps = _ref.pageProps,
28
28
  _ref$muiTheme = _ref.muiTheme,
29
- muiTheme = _ref$muiTheme === void 0 ? null : _ref$muiTheme,
29
+ muiTheme = _ref$muiTheme === void 0 ? {} : _ref$muiTheme,
30
30
  _ref$onAuthentication = _ref.onAuthenticationLoaded,
31
31
  onAuthenticationLoaded = _ref$onAuthentication === void 0 ? null : _ref$onAuthentication;
32
32
  var _useState = (0, _react.useState)(false),
@@ -73,10 +73,10 @@ function AuthScapeApp(_ref) {
73
73
  }, 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, {
74
74
  setCurrentUser: setCurrentUser,
75
75
  isEnabled: process.env.enableAuth,
76
- userLoaded: function userLoaded() {
76
+ userLoaded: function userLoaded(signedInUser) {
77
77
  setLoadedUser(true);
78
78
  if (onAuthenticationLoaded != null) {
79
- onAuthenticationLoaded(currentUser);
79
+ onAuthenticationLoaded(signedInUser);
80
80
  }
81
81
  }
82
82
  }, /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
@@ -2312,31 +2312,33 @@ function AuthorizationComponent(_ref) {
2312
2312
  setLoaded = _useState2[1];
2313
2313
  var validateUserSignedIn = /*#__PURE__*/function () {
2314
2314
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
2315
- var usr;
2315
+ var signedInUser, usr;
2316
2316
  return _regeneratorRuntime().wrap(function _callee$(_context) {
2317
2317
  while (1) switch (_context.prev = _context.next) {
2318
2318
  case 0:
2319
2319
  setLoaded(true);
2320
+ signedInUser = null;
2320
2321
  if (!isEnabled) {
2321
- _context.next = 8;
2322
+ _context.next = 9;
2322
2323
  break;
2323
2324
  }
2324
- _context.next = 4;
2325
+ _context.next = 5;
2325
2326
  return apiService().GetCurrentUser();
2326
- case 4:
2327
+ case 5:
2327
2328
  usr = _context.sent;
2328
2329
  if (usr != null) {
2329
2330
  setCurrentUser(usr);
2331
+ signedInUser = usr;
2330
2332
  } else {
2331
2333
  setCurrentUser(null);
2332
2334
  }
2333
- _context.next = 9;
2335
+ _context.next = 10;
2334
2336
  break;
2335
- case 8:
2336
- setCurrentUser(null);
2337
2337
  case 9:
2338
- userLoaded();
2338
+ setCurrentUser(null);
2339
2339
  case 10:
2340
+ userLoaded(signedInUser);
2341
+ case 11:
2340
2342
  case "end":
2341
2343
  return _context.stop();
2342
2344
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.188",
3
+ "version": "1.0.192",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -6,7 +6,7 @@ import { useRouter } from 'next/router';
6
6
  import { ThemeProvider } from '@mui/material/styles';
7
7
  import { Box } from '@mui/material';
8
8
 
9
- export function AuthScapeApp({Component, pageProps, muiTheme = null, onAuthenticationLoaded = null}) {
9
+ export function AuthScapeApp({Component, pageProps, muiTheme = {}, onAuthenticationLoaded = null}) {
10
10
 
11
11
  const [isLoading, setIsLoading] = useState(false);
12
12
  const [loadedUser, setLoadedUser] = useState(false);
@@ -58,12 +58,12 @@ export function AuthScapeApp({Component, pageProps, muiTheme = null, onAuthentic
58
58
 
59
59
  {!loadingLogin &&
60
60
  <>
61
- <AuthorizationComponent setCurrentUser={setCurrentUser} isEnabled={process.env.enableAuth} userLoaded={() => {
61
+ <AuthorizationComponent setCurrentUser={setCurrentUser} isEnabled={process.env.enableAuth} userLoaded={(signedInUser) => {
62
62
  setLoadedUser(true);
63
63
 
64
64
  if (onAuthenticationLoaded != null)
65
65
  {
66
- onAuthenticationLoaded(currentUser);
66
+ onAuthenticationLoaded(signedInUser);
67
67
  }
68
68
  }}>
69
69
  <Component {...pageProps} currentUser={currentUser} toast={toast} setIsLoading={setIsLoading} loadedUser={loadedUser} logEvent={logEvent} />
@@ -8,12 +8,14 @@ export function AuthorizationComponent({children, isEnabled, setCurrentUser, use
8
8
 
9
9
  setLoaded(true);
10
10
 
11
+ let signedInUser = null;
11
12
  if (isEnabled)
12
13
  {
13
14
  let usr = await apiService().GetCurrentUser();
14
15
  if (usr != null)
15
16
  {
16
17
  setCurrentUser(usr);
18
+ signedInUser = usr;
17
19
  }
18
20
  else
19
21
  {
@@ -25,7 +27,7 @@ export function AuthorizationComponent({children, isEnabled, setCurrentUser, use
25
27
  setCurrentUser(null);
26
28
  }
27
29
 
28
- userLoaded();
30
+ userLoaded(signedInUser);
29
31
  }
30
32
 
31
33
  useEffect(() => {