authscape 1.0.558 → 1.0.560
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 +28 -3
- package/package.json +1 -1
- package/src/components/AuthScapeApp.js +39 -3
package/index.js
CHANGED
|
@@ -349,6 +349,31 @@ function AuthScapeApp(_ref) {
|
|
|
349
349
|
_reactToastify.toast.error(message);
|
|
350
350
|
}
|
|
351
351
|
};
|
|
352
|
+
var GetSignedInUser = function GetSignedInUser() {
|
|
353
|
+
var signedInUser = signedInUser.current;
|
|
354
|
+
|
|
355
|
+
// create the prototype for reading role and permission
|
|
356
|
+
|
|
357
|
+
signedInUser.HasRole = function (name) {
|
|
358
|
+
if (currentUser.roles.find(function (r) {
|
|
359
|
+
return r.name === name;
|
|
360
|
+
}) != null) {
|
|
361
|
+
return true;
|
|
362
|
+
} else {
|
|
363
|
+
return false;
|
|
364
|
+
}
|
|
365
|
+
};
|
|
366
|
+
signedInUser.HasPermission = function (name) {
|
|
367
|
+
if (currentUser.Permissions.find(function (r) {
|
|
368
|
+
return r === name;
|
|
369
|
+
}) != null) {
|
|
370
|
+
return true;
|
|
371
|
+
} else {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
return signedInUser;
|
|
376
|
+
};
|
|
352
377
|
var useStore = (0, _zustand.create)(function (set) {
|
|
353
378
|
return store;
|
|
354
379
|
});
|
|
@@ -362,7 +387,7 @@ function AuthScapeApp(_ref) {
|
|
|
362
387
|
theme: muiTheme
|
|
363
388
|
}, frontEndLoadedState != null && frontEndLoadedState && pathname != "/signin-oidc" && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, layout != null && layout({
|
|
364
389
|
children: /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
|
|
365
|
-
currentUser:
|
|
390
|
+
currentUser: GetSignedInUser(),
|
|
366
391
|
loadedUser: frontEndLoadedState,
|
|
367
392
|
setIsLoading: setIsLoading,
|
|
368
393
|
logEvent: logEvent,
|
|
@@ -374,7 +399,7 @@ function AuthScapeApp(_ref) {
|
|
|
374
399
|
setWarnToastMessage: setWarnToastMessage,
|
|
375
400
|
setErrorToastMessage: setErrorToastMessage
|
|
376
401
|
})),
|
|
377
|
-
currentUser:
|
|
402
|
+
currentUser: GetSignedInUser(),
|
|
378
403
|
logEvent: logEvent,
|
|
379
404
|
setIsLoading: setIsLoading,
|
|
380
405
|
toast: _reactToastify.toast,
|
|
@@ -386,7 +411,7 @@ function AuthScapeApp(_ref) {
|
|
|
386
411
|
setWarnToastMessage: setWarnToastMessage,
|
|
387
412
|
setErrorToastMessage: setErrorToastMessage
|
|
388
413
|
}), layout == null && /*#__PURE__*/_react["default"].createElement(Component, _extends({}, pageProps, {
|
|
389
|
-
currentUser:
|
|
414
|
+
currentUser: GetSignedInUser(),
|
|
390
415
|
loadedUser: frontEndLoadedState,
|
|
391
416
|
setIsLoading: setIsLoading,
|
|
392
417
|
logEvent: logEvent,
|
package/package.json
CHANGED
|
@@ -335,6 +335,42 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
335
335
|
}
|
|
336
336
|
|
|
337
337
|
|
|
338
|
+
const GetSignedInUser = () => {
|
|
339
|
+
|
|
340
|
+
let signedInUser = signedInUser.current;
|
|
341
|
+
|
|
342
|
+
// create the prototype for reading role and permission
|
|
343
|
+
|
|
344
|
+
signedInUser.HasRole = function(name) {
|
|
345
|
+
|
|
346
|
+
if (currentUser.roles.find(r => r.name === name) != null)
|
|
347
|
+
{
|
|
348
|
+
return true;
|
|
349
|
+
}
|
|
350
|
+
else
|
|
351
|
+
{
|
|
352
|
+
return false;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
signedInUser.HasPermission = function(name) {
|
|
358
|
+
|
|
359
|
+
if (currentUser.Permissions.find(r => r === name) != null)
|
|
360
|
+
{
|
|
361
|
+
return true;
|
|
362
|
+
}
|
|
363
|
+
else
|
|
364
|
+
{
|
|
365
|
+
return false;
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
};
|
|
369
|
+
|
|
370
|
+
return signedInUser;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
|
|
338
374
|
const useStore = create((set) => (store));
|
|
339
375
|
|
|
340
376
|
return (
|
|
@@ -353,8 +389,8 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
353
389
|
{frontEndLoadedState != null && frontEndLoadedState && pathname != "/signin-oidc" &&
|
|
354
390
|
<>
|
|
355
391
|
{layout != null && layout({
|
|
356
|
-
children: <Component {...pageProps} currentUser={
|
|
357
|
-
currentUser:
|
|
392
|
+
children: <Component {...pageProps} currentUser={GetSignedInUser()} loadedUser={frontEndLoadedState} setIsLoading={setIsLoading} logEvent={logEvent} logPurchase={logPurchase} store={useStore} setToastMessage={setToastMessage} setInfoToastMessage={setInfoToastMessage} setSuccessToastMessage={setSuccessToastMessage} setWarnToastMessage={setWarnToastMessage} setErrorToastMessage={setErrorToastMessage} />,
|
|
393
|
+
currentUser: GetSignedInUser(),
|
|
358
394
|
logEvent: logEvent,
|
|
359
395
|
setIsLoading: setIsLoading,
|
|
360
396
|
toast: toast,
|
|
@@ -368,7 +404,7 @@ export function AuthScapeApp ({Component, layout, loadingLayout, pageProps, muiT
|
|
|
368
404
|
})}
|
|
369
405
|
|
|
370
406
|
{layout == null &&
|
|
371
|
-
<Component {...pageProps} currentUser={
|
|
407
|
+
<Component {...pageProps} currentUser={GetSignedInUser()} loadedUser={frontEndLoadedState} setIsLoading={setIsLoading} logEvent={logEvent} logPurchase={logPurchase} store={useStore} setToastMessage={setToastMessage} setInfoToastMessage={setInfoToastMessage} setSuccessToastMessage={setSuccessToastMessage} setWarnToastMessage={setWarnToastMessage} setErrorToastMessage={setErrorToastMessage} />
|
|
372
408
|
}
|
|
373
409
|
</>
|
|
374
410
|
}
|