mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-06 04:51:44 -07:00
fix: stop redundant fetching /auth/login
This commit is contained in:
parent
4151978a68
commit
ce9f7943c0
1 changed files with 19 additions and 10 deletions
|
@ -1,13 +1,18 @@
|
|||
import { useEffect } from "react";
|
||||
import { Grid, Typography } from "@material-ui/core";
|
||||
import { useLocalStorage } from "react-use";
|
||||
import axios from "axios";
|
||||
import { useHistory } from "react-router-dom";
|
||||
|
||||
import axios from "axios";
|
||||
|
||||
function HomeLoggedOut() {
|
||||
const [, setLoggedIn] = useLocalStorage("loggedIn", false);
|
||||
const [, setToken] = useLocalStorage("token", null);
|
||||
const [, setDisableAuth] = useLocalStorage("disableAuth", false);
|
||||
const history = useHistory();
|
||||
|
||||
useEffect(() => {
|
||||
async function fetchData() {
|
||||
axios.get("/auth/login").then(function (response) {
|
||||
if (!response.data.enabled) {
|
||||
setLoggedIn(true);
|
||||
|
@ -18,6 +23,10 @@ function HomeLoggedOut() {
|
|||
setDisableAuth(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
fetchData();
|
||||
}, [history, setDisableAuth, setLoggedIn, setToken]);
|
||||
|
||||
return (
|
||||
<Grid
|
||||
container
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue