1
0
Fork 0
mirror of https://github.com/mealie-recipes/mealie.git synced 2025-07-24 15:49:42 +02:00

feat: Redirect Logged Out Users to Default Group, If It's Public (#2772)
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

* 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>
This commit is contained in:
Michael Genson 2024-02-07 10:53:55 -06:00 committed by GitHub
parent e686fa671c
commit f42114e966
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 50 additions and 3 deletions

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();
}
}
});