Merge branch '27190_loggedin' into 'master'
27190_loggedin See merge request !53
Showing
3 changed files
with
52 additions
and
1 deletions
| ... | @@ -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_BTCOMPONENT_S3_URL%/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_AUTH_FAILED_REDIRECTION_URL%'; | ||
| 34 | } else { | ||
| 35 | let objBody = { aiwp_logged_in: aiUser }; | ||
| 36 | |||
| 37 | let params = []; | ||
| 38 | params['objBody'] = objBody; | ||
| 39 | params['strUrl'] = '%REACT_APP_EXTERNAL_API_URL%/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_AUTH_FAILED_REDIRECTION_URL%'; | ||
| 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> | ... | ... |
| ... | @@ -57,7 +57,28 @@ function App() { | ... | @@ -57,7 +57,28 @@ function App() { |
| 57 | 57 | ||
| 58 | async function handleSubmit(e){ | 58 | async function handleSubmit(e){ |
| 59 | e.preventDefault(); | 59 | e.preventDefault(); |
| 60 | let aiUser = window.btutil_getCookie('aiwp_logged_in'); | ||
| 61 | if(!aiUser) { | ||
| 62 | window.location.href = process.env.REACT_APP_AUTH_FAILED_REDIRECTION_URL; | ||
| 63 | return; | ||
| 64 | } else { | ||
| 65 | let objBody = { aiwp_logged_in: aiUser }; | ||
| 66 | |||
| 67 | let params = []; | ||
| 68 | params['objBody'] = objBody; | ||
| 69 | params['strUrl'] = process.env.REACT_APP_EXTERNAL_API_URL + '/e/v1/authenticate/'; | ||
| 70 | |||
| 71 | window.btutil_checkAuthentication(params, function(res) { | ||
| 72 | if (!res.success) { | ||
| 73 | window.location.href = process.env.REACT_APP_AUTH_FAILED_REDIRECTION_URL; | ||
| 74 | } else { | ||
| 75 | submitPrompt(); | ||
| 76 | } | ||
| 77 | }, function(res) {}); | ||
| 78 | } | ||
| 79 | } | ||
| 60 | 80 | ||
| 81 | async function submitPrompt() { | ||
| 61 | const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who']; | 82 | const userInput = ['what', 'why', 'when', 'where' , 'which', 'did', 'do', 'how', 'can', 'are', 'who']; |
| 62 | const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi'); | 83 | const userInputRegex = new RegExp(`\\b(${userInput.join('|')})\\b`, 'gi'); |
| 63 | const inputMatches = chatInput.match(userInputRegex); | 84 | const inputMatches = chatInput.match(userInputRegex); |
| ... | @@ -91,7 +112,6 @@ function App() { | ... | @@ -91,7 +112,6 @@ function App() { |
| 91 | messages = JSON.stringify(chatLogTurboNew); | 112 | messages = JSON.stringify(chatLogTurboNew); |
| 92 | } | 113 | } |
| 93 | let intervalId = startInterval(); | 114 | let intervalId = startInterval(); |
| 94 | |||
| 95 | try { | 115 | try { |
| 96 | const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", { | 116 | const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", { |
| 97 | method: "POST", | 117 | method: "POST", | ... | ... |
| ... | @@ -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 | ... | ... |
-
Please register or sign in to post a comment