Updated login stuff plus logout button works now
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import MenuIcon from '@mui/material/Menu'
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import {red, green, lightBlue, lightGreen} from '@mui/material/colors';
|
||||
import { ThemeProvider, createTheme } from '@mui/material/styles';
|
||||
|
||||
import { ReactSession } from 'react-client-session';
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,12 @@ function MyPlan() {
|
||||
}
|
||||
const navigateLogin = () => {
|
||||
navigate('/');
|
||||
}
|
||||
|
||||
const logout = () => {
|
||||
ReactSession.set("net_id", "");
|
||||
navigateLogin();
|
||||
|
||||
}
|
||||
|
||||
return (
|
||||
@@ -67,7 +73,7 @@ const navigateLogin = () => {
|
||||
</Button>
|
||||
<Button variant="h6"onClick={Past} >
|
||||
Past Plans</Button>
|
||||
<Button variant="h6" color="main" component="div" onClick={navigateLogin} sx={{
|
||||
<Button variant="h6" color="main" component="div" onClick={logout} sx={{
|
||||
':hover': {
|
||||
bgcolor: '#ffc6c4', // theme.palette.primary.main
|
||||
color: 'red',
|
||||
|
||||
Reference in New Issue
Block a user