fix: admin users were created while the setup wizard wasn't finished

This commit is contained in:
Elias Schneider
2023-01-26 15:43:13 +01:00
parent 7e91038a24
commit ad92cfc852
8 changed files with 37 additions and 22 deletions

View File

@@ -112,15 +112,7 @@ const AdminConfigTable = () => {
<Group position="right">
<Button
onClick={() => {
if (config.get("SETUP_FINISHED")) {
configService
.updateMany(updatedConfigVariables)
.then(() => {
updatedConfigVariables = [];
toast.success("Configurations updated successfully");
})
.catch(toast.axiosError);
} else {
if (config.get("SETUP_STATUS") == "REGISTERED") {
configService
.updateMany(updatedConfigVariables)
.then(async () => {
@@ -128,6 +120,14 @@ const AdminConfigTable = () => {
window.location.reload();
})
.catch(toast.axiosError);
} else {
configService
.updateMany(updatedConfigVariables)
.then(() => {
updatedConfigVariables = [];
toast.success("Configurations updated successfully");
})
.catch(toast.axiosError);
}
}}
>

View File

@@ -46,15 +46,24 @@ function App({ Component, pageProps }: AppProps) {
getInitalData();
}, []);
// Redirect to setup page if setup is not completed
useEffect(() => {
if (
configVariables &&
configVariables.filter((variable) => variable.key)[0].value == "false" &&
!["/auth/signUp", "/admin/setup"].includes(router.asPath)
) {
router.push(!user ? "/auth/signUp" : "/admin/setup");
const setupStatus = configVariables.filter(
(variable) => variable.key == "SETUP_STATUS"
)[0].value;
if (setupStatus == "STARTED") {
router.replace("/auth/signUp");
} else if (user && setupStatus == "REGISTERED") {
router.replace("/admin/setup");
} else if (setupStatus == "REGISTERED") {
router.replace("/auth/signIn");
}
}
}, [router.asPath]);
}, [configVariables, router.asPath]);
useEffect(() => {
setColorScheme(

View File

@@ -15,7 +15,7 @@ const Setup = () => {
if (!user) {
router.push("/auth/signUp");
return;
} else if (config.get("SETUP_FINISHED")) {
} else if (config.get("SETUP_STATUS") == "FINISHED") {
router.push("/");
return;
}