1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-21 14:19:41 +02:00
mealie/frontend/pages/index.vue
Michael Genson f42114e966
Some checks are pending
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Docker Nightly Production / Backend Server Tests (push) Waiting to run
Docker Nightly Production / Frontend and End-to-End Tests (push) Waiting to run
Docker Nightly Production / Build Tagged Release (push) Blocked by required conditions
Docker Nightly Production / Notify Discord (push) Blocked by required conditions
feat: Redirect Logged Out Users to Default Group, If It's Public (#2772)
* add default group slug to app info if public

* redirect public user to default group

* added tests

---------

Co-authored-by: Kuchenpirat <24235032+Kuchenpirat@users.noreply.github.com>
2024-02-07 07:53:55 -09:00

32 lines
824 B
Vue

<template>
<div></div>
</template>
<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, $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 {
redirectPublicUserToDefaultGroup();
}
}
});
</script>