This repository has been archived by the owner on Apr 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
278f5fc
commit a95e3ad
Showing
8 changed files
with
143 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,69 @@ | ||
import axios from 'axios'; | ||
import localStorage from 'localStorage'; | ||
|
||
export const connect = async (userData, env = 'https://alpha.mindsdb.com') => { | ||
|
||
const { email, password } = userData; | ||
if (!email || !password) { | ||
return { | ||
error: true, | ||
message: 'Please add email or password', | ||
}; | ||
} | ||
|
||
try { | ||
const loginResponse = await axios.post(`${env}/cloud/login`, userData); | ||
const requestCookie = loginResponse.headers['set-cookie']; | ||
const statusResponse = await axios.get(`${env}/cloud/status`, { | ||
headers: { | ||
Cookie: requestCookie, | ||
}, | ||
}); | ||
|
||
localStorage.setItem('auth', JSON.stringify(loginResponse.data)); | ||
localStorage.setItem('requestCookie', requestCookie[4]); | ||
|
||
// console.log( | ||
// JSON.stringify({ | ||
// Cookie: requestCookie, | ||
// }) | ||
// ); | ||
return statusResponse.data; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
// const loginResponse = await axios | ||
// .post(`${env}/cloud/login`, userData) | ||
|
||
// .then((response) => { | ||
// localStorage.setItem("auth", JSON.stringify(response.data)); | ||
// console.log("loginResponse =>", response); | ||
// console.log("pos", localStorage.getItem("auth")); | ||
// return response.data; | ||
// }) | ||
// .catch((err) => { | ||
// console.log(JSON.stringify(err)); // Error handler | ||
// }); | ||
export const connect = async (userData) => { | ||
const { email, password } = userData; | ||
|
||
// return await axios | ||
// .get(`${env}/cloud/status`, { | ||
// withCredentials: true, | ||
// }) | ||
// .then((response) => { | ||
// console.log("pos", localStorage.getItem("auth")); | ||
// return response; | ||
if (!email || !password) { | ||
return { | ||
error: true, | ||
message: 'Please add email or password', | ||
}; | ||
} | ||
|
||
try { | ||
const loginResponse = await axios.post(`/cloud/login`, userData, { | ||
headers: { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': '*', | ||
'Access-Control-Allow-Credentials': 'true', | ||
}, | ||
}); | ||
const requestCookie = loginResponse.headers['set-cookie']; | ||
const statusResponse = await axios.get(`/cloud/status`, { | ||
headers: { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': '*', | ||
'Access-Control-Allow-Credentials': 'true', | ||
Cookie: requestCookie, | ||
}, | ||
}); | ||
|
||
localStorage.setItem('auth', JSON.stringify(loginResponse.data)); | ||
localStorage.setItem('requestCookie', requestCookie[4]); | ||
|
||
// console.log( | ||
// JSON.stringify({ | ||
// Cookie: requestCookie, | ||
// }) | ||
// .catch((err) => { | ||
// console.log(JSON.stringify(err)); // Error handler | ||
// }); | ||
// ); | ||
return statusResponse.data; | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
|
||
// const loginResponse = await axios | ||
// .post(`${env}/cloud/login`, userData) | ||
|
||
// .then((response) => { | ||
// localStorage.setItem("auth", JSON.stringify(response.data)); | ||
// console.log("loginResponse =>", response); | ||
// console.log("pos", localStorage.getItem("auth")); | ||
// return response.data; | ||
// }) | ||
// .catch((err) => { | ||
// console.log(JSON.stringify(err)); // Error handler | ||
// }); | ||
|
||
// return await axios | ||
// .get(`${env}/cloud/status`, { | ||
// withCredentials: true, | ||
// }) | ||
// .then((response) => { | ||
// console.log("pos", localStorage.getItem("auth")); | ||
// return response; | ||
// }) | ||
// .catch((err) => { | ||
// console.log(JSON.stringify(err)); // Error handler | ||
// }); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import localStorage from 'localStorage'; | ||
|
||
export const getStatus = async () => { | ||
try { | ||
console.log('post', localStorage.getItem('requestCookie')); | ||
return localStorage.getItem('requestCookie'); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
try { | ||
console.log('post', localStorage.getItem('requestCookie')); | ||
return localStorage.getItem('requestCookie'); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters