Updated login stuff plus logout button works now

This commit is contained in:
Ava DeCroix
2023-04-29 22:52:09 -04:00
parent 86ecb279de
commit 24c5eb4b5e
3 changed files with 23 additions and 7 deletions

View File

@@ -34,6 +34,10 @@ export function Login() {
navigate('/CreateAccount');
}
const navigateHome = () => {
navigate('/Plan');
}
const [data,setData] = useState({
net_id:"",
password:""
@@ -50,11 +54,12 @@ const [data,setData] = useState({
console.log(data);
console.log(net_id[0])
login();
ReactSession.set("username", net_id[0]);
ReactSession.set("password", password[0]);
}
const setSession = () => {
ReactSession.set("net_id", net_id[0]);
}
const getHello = () => {
@@ -66,7 +71,12 @@ const getHello = () => {
const login = () => {
Axios.post("http://3.219.93.142:8000/api/auth", {net_id: net_id[0], password: password[0],}).then((response) => {
console.log(response);
console.log(response.status)
console.log(response.status);
if (response.status === 200){
setSession();
navigateHome();
}
});
};