68aee7cc by Jonille Arreglo

27190_loggedin

1 parent 5ae7a722
...@@ -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",
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!