1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-08-05 13:35:23 +02:00

Merge branch 'mealie-next' into feat-frontend-access-controll

This commit is contained in:
Kuchenpirat 2024-02-07 18:22:55 +01:00 committed by GitHub
commit 704d0a8392
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 173 additions and 41 deletions

View file

@ -33,6 +33,7 @@ export interface AppInfo {
version: string;
demoStatus: boolean;
allowSignup: boolean;
defaultGroupSlug?: string;
}
export interface AppStartupInfo {
isFirstLogin: boolean;

View file

@ -4,17 +4,28 @@
<script lang="ts">
import { computed, defineComponent, useContext, useRouter } from "@nuxtjs/composition-api";
import { AppInfo } from "~/lib/api/types/admin";
export default defineComponent({
layout: "blank",
setup() {
const { $auth } = useContext();
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");
}
}
if (groupSlug.value) {
router.push(`/g/${groupSlug.value}`);
} else {
router.push("/login");
redirectPublicUserToDefaultGroup();
}
}
});