mealie/frontend/pages/index.vue
Michael Genson 403038a5b2
feat: First Time Setup Wizard (#3204)
* extract user registration form into a composable

* added base wizard component

* added partial setup implementation

* removed unused attrs

* added setup bypass

* made setup page more readable

* add checkbox hints to autoform

* added common settings pages and initial submit logic

* bypass setup in demo

* add full name to user registration

* added fullname and pw handling to setup

* fixed wizard indentation

* added post-setup suggestions

* added tests for backend changes

* renamed Wizard to BaseWizard

* lint fixes

* pass hardcoded default password instead of backend nonsense

* removed old test

* fix e2e

* added setup skip to e2e testing for all admin users

---------

Co-authored-by: Hayden <64056131+hay-kot@users.noreply.github.com>
2024-03-11 13:28:54 +00:00

43 lines
1.2 KiB
Vue

<template>
<div></div>
</template>
<script lang="ts">
import { computed, defineComponent, useAsync, useContext, useRouter } from "@nuxtjs/composition-api";
import { useAsyncKey } from "~/composables/use-utils";
import { AppInfo, AppStartupInfo } from "~/lib/api/types/admin";
export default defineComponent({
layout: "blank",
setup() {
const { $auth, $axios } = useContext();
const router = useRouter();
const groupSlug = computed(() => $auth.user?.groupSlug);
async function redirectPublicUserToDefaultGroup() {
const { data } = await $axios.get<AppInfo>("/api/app/about");
if (data?.defaultGroupSlug) {
router.push(`/g/${data.defaultGroupSlug}`);
} else {
router.push("/login");
}
}
useAsync(async () => {
if (groupSlug.value) {
const data = await $axios.get<AppStartupInfo>("/api/app/about/startup-info");
const isDemo = data.data.isDemo;
const isFirstLogin = data.data.isFirstLogin;
if (!isDemo && isFirstLogin && $auth.user?.admin) {
router.push("/admin/setup");
} else {
router.push(`/g/${groupSlug.value}`);
}
} else {
redirectPublicUserToDefaultGroup();
}
}, useAsyncKey());
}
});
</script>