fixed login redirect
This commit is contained in:
@@ -12,7 +12,7 @@ import Grid from '@material-ui/core/Grid';
|
||||
import Link1 from '@material-ui/core/Link';
|
||||
import { Redirect } from "react-router-dom";
|
||||
|
||||
const url = "/simcompanies/API/user/login"
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
card: {
|
||||
backgroundColor: "#0B1929",
|
||||
@@ -59,6 +59,15 @@ const CssTextField = withStyles({
|
||||
},
|
||||
})(TextField);
|
||||
|
||||
|
||||
export default function Login() {
|
||||
const classes = useStyles();
|
||||
const url = "/simcompanies/API/user/login"
|
||||
const [username, setUsername] = React.useState("");
|
||||
const [password, setPassword] = React.useState("");
|
||||
const [login, setLogin] = React.useState(true);
|
||||
|
||||
|
||||
const postLogin = async (url, data) => {
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
@@ -73,18 +82,10 @@ const postLogin = async (url, data) => {
|
||||
});
|
||||
|
||||
if (response.status == "200") {
|
||||
return <Redirect to={"/"} />
|
||||
setLogin(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
export default function Login() {
|
||||
const classes = useStyles();
|
||||
|
||||
const [username, setUsername] = React.useState("");
|
||||
const [password, setPassword] = React.useState("");
|
||||
|
||||
const handleClick = (e) => {
|
||||
|
||||
if (username !== "" && password !== "") {
|
||||
@@ -100,7 +101,11 @@ export default function Login() {
|
||||
const handleChangePW = (e) => {
|
||||
setPassword(e.target.value)
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
|
||||
login === true ?
|
||||
< Box className="loginBackground" display="flex" justifyContent="center" alignItems="center" m={1} p={1} >
|
||||
<Card className={classes.card} raised>
|
||||
<CardContent>
|
||||
@@ -164,7 +169,7 @@ export default function Login() {
|
||||
</form>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</Box >
|
||||
</Box > : <Redirect to='/' />
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user