authscape 1.0.196 → 1.0.200

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
@@ -12,6 +12,7 @@ var _reactToastify = require("react-toastify");
12
12
  var _router = require("next/router");
13
13
  var _styles = require("@mui/material/styles");
14
14
  var _material = require("@mui/material");
15
+ var _head = _interopRequireDefault(require("next/head"));
15
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
17
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
18
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -47,6 +48,10 @@ function AuthScapeApp(_ref) {
47
48
  _useState8 = _slicedToArray(_useState7, 2),
48
49
  loadingLogin = _useState8[0],
49
50
  setLoadingLogin = _useState8[1];
51
+ var _useState9 = (0, _react.useState)(null),
52
+ _useState10 = _slicedToArray(_useState9, 2),
53
+ domainData = _useState10[0],
54
+ setDomainData = _useState10[1];
50
55
  var router = (0, _router.useRouter)();
51
56
  // const [openLoginModal, setOpenLoginModal] = useState(false);
52
57
 
@@ -60,11 +65,13 @@ function AuthScapeApp(_ref) {
60
65
  }
61
66
 
62
67
  // ORM module
63
- // if (process.env.enableOEMClient)
64
- // {
65
- // var baseURL = window.location.protocol + "//" + window.location.host;
66
- // apiService().get("/oem/")
67
- // }
68
+ if (process.env.enableOEMClient) {
69
+ var baseURL = window.location.protocol + "//" + window.location.host;
70
+ var response = apiService().get("/oem/GetDataFromRecord?domain=" + baseURL);
71
+ if (response != null && response.status == 200) {
72
+ setDomainData(response.data);
73
+ }
74
+ }
68
75
  }
69
76
  }, [loadedUser]);
70
77
  (0, _react.useEffect)(function () {
@@ -79,12 +86,18 @@ function AuthScapeApp(_ref) {
79
86
  }, [router.isReady]);
80
87
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_styles.ThemeProvider, {
81
88
  theme: muiTheme
82
- }, 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, {
89
+ }, /*#__PURE__*/_react["default"].createElement(_head["default"], null, /*#__PURE__*/_react["default"].createElement("meta", {
90
+ name: "viewport",
91
+ content: "width=device-width, initial-scale=1"
92
+ }), domainData != null && domainData.globalCSS != undefined && /*#__PURE__*/_react["default"].createElement("style", null, domainData.globalCSS), domainData != null && domainData.fontFamily != undefined && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("link", {
93
+ rel: "stylesheet",
94
+ href: "https://fonts.googleapis.com/css2?family=" + domainData.fontFamily + "&display=swap"
95
+ }), /*#__PURE__*/_react["default"].createElement("style", null, "body{font-family:\"" + domainData.fontFamily + "\" !important;}button{font-family:\"" + domainData.fontFamily + "\" !important;}"))), 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, {
83
96
  setCurrentUser: setCurrentUser,
84
97
  isEnabled: process.env.enableAuth,
85
98
  userLoaded: function userLoaded(signedInUser) {
86
99
  setLoadedUser(true);
87
- if (enforceLoggedIn) {
100
+ if (enforceLoggedIn && signedInUser == null) {
88
101
  authService().login();
89
102
  } else {
90
103
  if (onAuthenticationLoaded != null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "authscape",
3
- "version": "1.0.196",
3
+ "version": "1.0.200",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -5,6 +5,7 @@ import { ToastContainer, toast } from 'react-toastify';
5
5
  import { useRouter } from 'next/router';
6
6
  import { ThemeProvider } from '@mui/material/styles';
7
7
  import { Box } from '@mui/material';
8
+ import Head from "next/head";
8
9
 
9
10
  export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLoggedIn = false, onAuthenticationLoaded = null}) {
10
11
 
@@ -12,6 +13,7 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
12
13
  const [loadedUser, setLoadedUser] = useState(false);
13
14
  const [currentUser, setCurrentUser] = useState(null);
14
15
  const [loadingLogin, setLoadingLogin] = useState(false);
16
+ const [domainData, setDomainData] = useState(null);
15
17
  const router = useRouter();
16
18
  // const [openLoginModal, setOpenLoginModal] = useState(false);
17
19
 
@@ -29,11 +31,15 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
29
31
  }
30
32
 
31
33
  // ORM module
32
- // if (process.env.enableOEMClient)
33
- // {
34
- // var baseURL = window.location.protocol + "//" + window.location.host;
35
- // apiService().get("/oem/")
36
- // }
34
+ if (process.env.enableOEMClient)
35
+ {
36
+ var baseURL = window.location.protocol + "//" + window.location.host;
37
+ let response = apiService().get("/oem/GetDataFromRecord?domain=" + baseURL);
38
+ if (response != null && response.status == 200)
39
+ {
40
+ setDomainData(response.data);
41
+ }
42
+ }
37
43
 
38
44
  }
39
45
  }, [loadedUser]);
@@ -58,6 +64,23 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
58
64
  <>
59
65
  <ThemeProvider theme={muiTheme}>
60
66
 
67
+ <Head>
68
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
69
+
70
+ {(domainData != null && domainData.globalCSS != undefined) &&
71
+ <style>{domainData.globalCSS}</style>
72
+ }
73
+
74
+ {(domainData != null && domainData.fontFamily != undefined) &&
75
+ <>
76
+ <link rel="stylesheet" href={"https://fonts.googleapis.com/css2?family=" + domainData.fontFamily + "&display=swap"} />
77
+ <style>
78
+ {"body{font-family:\"" + domainData.fontFamily + "\" !important;}button{font-family:\"" + domainData.fontFamily + "\" !important;}"}
79
+ </style>
80
+ </>
81
+ }
82
+ </Head>
83
+
61
84
  {loadingLogin &&
62
85
  <Box>
63
86
  Please wait. Loading...
@@ -69,7 +92,7 @@ export function AuthScapeApp({Component, pageProps, muiTheme = {}, enforceLogged
69
92
  <AuthorizationComponent setCurrentUser={setCurrentUser} isEnabled={process.env.enableAuth} userLoaded={(signedInUser) => {
70
93
  setLoadedUser(true);
71
94
 
72
- if (enforceLoggedIn)
95
+ if (enforceLoggedIn && signedInUser == null)
73
96
  {
74
97
  authService().login();
75
98
  }