Skip setup step 4 (host/port) when override vars are set

- Modified setup/2.post.ts to check for WG_HOST and WG_CLIENT_PORT overrides
- If both overrides are set, auto-populate host/port and mark setup as complete
- Updated setup/2.vue to check setup status after user creation and redirect appropriately
- Modified setup middleware to allow access to success page during setup
- Setup now completes after step 2 when host/port are provided via environment variables

Co-authored-by: kaaax0815 <32197462+kaaax0815@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-11-17 09:49:53 +00:00
parent e5cdb2b57a
commit 516a3fa72c
3 changed files with 29 additions and 3 deletions
+9 -1
View File
@@ -57,7 +57,15 @@ const _submit = useSubmit(
{ {
revert: async (success) => { revert: async (success) => {
if (success) { if (success) {
await navigateTo('/setup/3'); // Check if setup is complete (host/port were auto-set from overrides)
const setupStatus = await $fetch('/api/general/setup');
if (setupStatus.done) {
// Setup is complete, redirect to success page
await navigateTo('/setup/success');
} else {
// Continue to step 3
await navigateTo('/setup/3');
}
} }
}, },
noSuccessToast: true, noSuccessToast: true,
+14 -1
View File
@@ -8,6 +8,19 @@ export default defineSetupEventHandler(2, async ({ event }) => {
await Database.users.create(username, password); await Database.users.create(username, password);
await Database.general.setSetupStep(3); // If host and port are overridden by environment variables, skip step 4
const host = WG_CLIENT_OVERRIDE_ENV.HOST;
const port = WG_CLIENT_OVERRIDE_ENV.CLIENT_PORT;
if (host && port) {
// Set the host and port from override variables
await Database.userConfigs.updateHostPort(host, port);
// Skip to done
await Database.general.setSetupStep(0);
} else {
// Proceed to step 3 (which leads to step 4)
await Database.general.setSetupStep(3);
}
return { success: true }; return { success: true };
}); });
+6 -1
View File
@@ -9,12 +9,17 @@ export default defineEventHandler(async (event) => {
const { step, done } = await Database.general.getSetupStep(); const { step, done } = await Database.general.getSetupStep();
if (!done) { if (!done) {
const parsedSetup = url.pathname.match(/\/setup\/(\d)/); const parsedSetup = url.pathname.match(/\/setup\/(\d|migrate|success)/);
if (!parsedSetup) { if (!parsedSetup) {
return sendRedirect(event, `/setup/1`, 302); return sendRedirect(event, `/setup/1`, 302);
} }
const [_, currentSetup] = parsedSetup; const [_, currentSetup] = parsedSetup;
// Allow access to success page during setup
if (currentSetup === 'success') {
return;
}
if (step.toString() === currentSetup) { if (step.toString() === currentSetup) {
return; return;
} }