import * as React from 'react'; import {Avatar, Checkbox, FormControlLabel, Grid, Link, Stack} from "@mui/material"; import Typography from "@mui/material/Typography"; import Container from "@mui/material/Container"; import LockOutlinedIcon from '@mui/icons-material/LockOutlined'; import TextField from "@mui/material/TextField"; import Button from "@mui/material/Button"; import Box from "@mui/material/Box"; import api from "../app/Api"; import {useNavigate} from "react-router-dom"; import routes from "./routes"; import session from "../app/Session"; const Copyright = (props) => { return ( {'Copyright © '} Your Website {' '} {new Date().getFullYear()} {'.'} ); }; const Login = () => { const handleSubmit = async (event) => { event.preventDefault(); const data = new FormData(event.currentTarget); console.log({ email: data.get('email'), password: data.get('password'), }); const user ={ username: data.get('email'), password: data.get('password'), } const token = await api.userAuth("http://localhost:2586"/*window.location.origin*/, user); console.log(`[Api] User auth for user ${user.username} successful, token is ${token}`); session.store(user.username, token); window.location.href = routes.app; }; return ( <> Sign in } label="Remember me" /> Forgot password? {"Don't have an account? Sign Up"} ); } export default Login;