mirror of
https://github.com/dec0dOS/zero-ui.git
synced 2025-07-05 20:41:43 -07:00
feat: support http basic auth
This commit is contained in:
parent
cd0276e598
commit
2396e973dc
2 changed files with 13 additions and 10 deletions
|
@ -13,16 +13,18 @@ function HomeLoggedOut() {
|
|||
|
||||
useEffect(() => {
|
||||
async function fetchData() {
|
||||
axios.get("/auth/login").then(function (response) {
|
||||
if (!response.data.enabled) {
|
||||
setLoggedIn(true);
|
||||
setDisableAuth(true);
|
||||
setToken("");
|
||||
history.go(0);
|
||||
} else {
|
||||
setDisableAuth(false);
|
||||
}
|
||||
});
|
||||
axios
|
||||
.get("/auth/login", { withCredentials: true })
|
||||
.then(function (response) {
|
||||
if (!response.data.enabled) {
|
||||
setLoggedIn(true);
|
||||
setDisableAuth(true);
|
||||
setToken("");
|
||||
history.go(0);
|
||||
} else {
|
||||
setDisableAuth(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
fetchData();
|
||||
}, [history, setDisableAuth, setLoggedIn, setToken]);
|
||||
|
|
|
@ -5,6 +5,7 @@ const baseURL = "/api/";
|
|||
export default axios.create({
|
||||
baseURL: baseURL,
|
||||
responseType: "json",
|
||||
withCredentials: "true",
|
||||
headers:
|
||||
localStorage.getItem("disableAuth") === "true"
|
||||
? {}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue