fix: admin users were created while the setup wizard wasn't finished
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user