147ec800 by Jonille Arreglo

27190_loggedin

1 parent bfa168cd
1 let aiUser = btutil_getCookie('aiwp_logged_in');
2 let objBody = { aiwp_logged_in: aiUser };
3
4 let params = [];
5 params['objBody'] = objBody;
6 params['strUrl'] = 'https://test.api.ai-pro.org/e/v1/authenticate/'; //use envvar for https://test.api.ai-pro.org/ only
7
8 btutil_checkAuthentication(params, cbCheckAuthentication, cbErrCheckAuthentication);
9 function cbCheckAuthentication(res) {
10 // console.log(res);
11 if (!res.success) {
12 window.location.href = "https://ai-pro.org/redirect-account-required/"; //use envvar
13 } else {
14 document.getElementById("root").classList.add("active");
15 }
16 }
17
18 function cbErrCheckAuthentication(res) {
19 console.log(res);
20 }
...\ No newline at end of file ...\ No newline at end of file
1 const appendScript = (scriptToAppend, callback = null) => {
2 const script = document.createElement("script");
3 script.src = scriptToAppend;
4 script.async = false;
5 document.body.appendChild(script);
6
7 if(!callback) return;
8 if(script.readyState) { // only required for IE <9
9 script.onreadystatechange = function() {
10 if ( script.readyState === "loaded" || script.readyState === "complete" ) {
11 script.onreadystatechange = null;
12 callback();
13 }
14 };
15 } else { //Others
16 script.onload = function() {
17 callback();
18 };
19 }
20 }
21
22 export default appendScript;
...\ No newline at end of file ...\ No newline at end of file
...@@ -11,3 +11,7 @@ code { ...@@ -11,3 +11,7 @@ code {
11 font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 11 font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12 monospace; 12 monospace;
13 } 13 }
14
15 #root:not(.active) {
16 display: none;
17 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -2,6 +2,7 @@ import React from 'react'; ...@@ -2,6 +2,7 @@ import React from 'react';
2 import ReactDOM from 'react-dom/client'; 2 import ReactDOM from 'react-dom/client';
3 import './index.css'; 3 import './index.css';
4 import App from './App'; 4 import App from './App';
5 import appendScript from './handlers/appendScript';
5 import reportWebVitals from './reportWebVitals'; 6 import reportWebVitals from './reportWebVitals';
6 7
7 const root = ReactDOM.createRoot(document.getElementById('root')); 8 const root = ReactDOM.createRoot(document.getElementById('root'));
...@@ -15,3 +16,6 @@ root.render( ...@@ -15,3 +16,6 @@ root.render(
15 // to log results (for example: reportWebVitals(console.log)) 16 // to log results (for example: reportWebVitals(console.log))
16 // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
17 reportWebVitals(); 18 reportWebVitals();
19
20 appendScript("https://btcomponent-1devt.s3.us-east-1.amazonaws.com/common/btutil-authenticate.min.js");
21 appendScript("http://localhost:3000/assets/js/auth.js");
...\ No newline at end of file ...\ No newline at end of file
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!