Merge branch '27190_loggedin' into '1DEVT'
27190_loggedin See merge request !52
Showing
5 changed files
with
30 additions
and
47 deletions
client/public/assets/js/auth.js
deleted
100644 → 0
| 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 |
| ... | @@ -26,6 +26,33 @@ | ... | @@ -26,6 +26,33 @@ |
| 26 | Learn how to configure a non-root public URL by running `npm run build`. | 26 | Learn how to configure a non-root public URL by running `npm run build`. |
| 27 | --> | 27 | --> |
| 28 | <title>AI-Pro ChatGPT</title> | 28 | <title>AI-Pro ChatGPT</title> |
| 29 | <script src='%REACT_APP_S3_LINK%/common/btutil-authenticate.min.js'></script> | ||
| 30 | <script> | ||
| 31 | let aiUser = btutil_getCookie('aiwp_logged_in'); | ||
| 32 | if(!aiUser) { | ||
| 33 | window.location.href = '%REACT_APP_REDIRECT_ACCOUNT%'; | ||
| 34 | } else { | ||
| 35 | let objBody = { aiwp_logged_in: aiUser }; | ||
| 36 | |||
| 37 | let params = []; | ||
| 38 | params['objBody'] = objBody; | ||
| 39 | params['strUrl'] = '%REACT_APP_API_LINK%/e/v1/authenticate/'; | ||
| 40 | |||
| 41 | btutil_checkAuthentication(params, cbCheckAuthentication, cbErrCheckAuthentication); | ||
| 42 | function cbCheckAuthentication(res) { | ||
| 43 | // console.log(res); | ||
| 44 | if (!res.success) { | ||
| 45 | window.location.href = '%REACT_APP_REDIRECT_ACCOUNT%'; | ||
| 46 | } else { | ||
| 47 | document.getElementById("root").classList.add("active"); | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | function cbErrCheckAuthentication(res) { | ||
| 52 | console.log(res); | ||
| 53 | } | ||
| 54 | } | ||
| 55 | </script> | ||
| 29 | </head> | 56 | </head> |
| 30 | <body> | 57 | <body> |
| 31 | <noscript>You need to enable JavaScript to run this app.</noscript> | 58 | <noscript>You need to enable JavaScript to run this app.</noscript> | ... | ... |
| ... | @@ -47,7 +47,9 @@ function App() { | ... | @@ -47,7 +47,9 @@ function App() { |
| 47 | let model_list = []; | 47 | let model_list = []; |
| 48 | for( var i = 1; i < data.models.data.length; i++ ) { | 48 | for( var i = 1; i < data.models.data.length; i++ ) { |
| 49 | let model = data.models.data[i]; | 49 | let model = data.models.data[i]; |
| 50 | if(model.id != "whisper-1") model_list.push(model); | 50 | if( !(model.id == "whisper-1" |
| 51 | || model.id == "gpt-4" | ||
| 52 | || model.id == "gpt-4-0314") ) model_list.push(model); | ||
| 51 | } | 53 | } |
| 52 | setModels(model_list) | 54 | setModels(model_list) |
| 53 | }) | 55 | }) | ... | ... |
client/src/handlers/appendScript.js
deleted
100644 → 0
| 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 |
| ... | @@ -2,7 +2,6 @@ import React from 'react'; | ... | @@ -2,7 +2,6 @@ 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'; | ||
| 6 | import reportWebVitals from './reportWebVitals'; | 5 | import reportWebVitals from './reportWebVitals'; |
| 7 | 6 | ||
| 8 | const root = ReactDOM.createRoot(document.getElementById('root')); | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); |
| ... | @@ -16,6 +15,3 @@ root.render( | ... | @@ -16,6 +15,3 @@ root.render( |
| 16 | // to log results (for example: reportWebVitals(console.log)) | 15 | // to log results (for example: reportWebVitals(console.log)) |
| 17 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals |
| 18 | reportWebVitals(); | 17 | 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 | ... | ... |
-
Please register or sign in to post a comment