mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-05-06 18:13:31 -04:00
fix: Don't hit authenticated endpoints when logged out (#7563)
This commit is contained in:
@@ -110,7 +110,7 @@ const route = useRoute();
|
|||||||
const groupSlug = computed(() => route.params.groupSlug as string || auth.user.value?.groupSlug || "");
|
const groupSlug = computed(() => route.params.groupSlug as string || auth.user.value?.groupSlug || "");
|
||||||
|
|
||||||
const cookbookPreferences = useCookbookPreferences();
|
const cookbookPreferences = useCookbookPreferences();
|
||||||
const ownCookbookStore = useCookbookStore(i18n);
|
const ownCookbookStore = computed(() => isOwnGroup.value ? useCookbookStore(i18n) : null);
|
||||||
const publicCookbookStoreCache = ref<Record<string, ReturnType<typeof usePublicCookbookStore>>>({});
|
const publicCookbookStoreCache = ref<Record<string, ReturnType<typeof usePublicCookbookStore>>>({});
|
||||||
|
|
||||||
function getPublicCookbookStore(slug: string) {
|
function getPublicCookbookStore(slug: string) {
|
||||||
@@ -121,8 +121,8 @@ function getPublicCookbookStore(slug: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cookbooks = computed(() => {
|
const cookbooks = computed(() => {
|
||||||
if (isOwnGroup.value) {
|
if (ownCookbookStore.value) {
|
||||||
return ownCookbookStore.store.value;
|
return ownCookbookStore.value.store.value;
|
||||||
}
|
}
|
||||||
else if (groupSlug.value) {
|
else if (groupSlug.value) {
|
||||||
const publicStore = getPublicCookbookStore(groupSlug.value);
|
const publicStore = getPublicCookbookStore(groupSlug.value);
|
||||||
|
|||||||
@@ -6,7 +6,12 @@ const loading = ref(false);
|
|||||||
|
|
||||||
export const useGroupSelf = function () {
|
export const useGroupSelf = function () {
|
||||||
const api = useUserApi();
|
const api = useUserApi();
|
||||||
|
const auth = useMealieAuth();
|
||||||
async function refreshGroupSelf() {
|
async function refreshGroupSelf() {
|
||||||
|
if (!auth.user.value) {
|
||||||
|
groupSelfRef.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const { data } = await api.groups.getCurrentUserGroup();
|
const { data } = await api.groups.getCurrentUserGroup();
|
||||||
groupSelfRef.value = data;
|
groupSelfRef.value = data;
|
||||||
|
|||||||
@@ -6,8 +6,13 @@ const loading = ref(false);
|
|||||||
|
|
||||||
export const useHouseholdSelf = function () {
|
export const useHouseholdSelf = function () {
|
||||||
const api = useUserApi();
|
const api = useUserApi();
|
||||||
|
const auth = useMealieAuth();
|
||||||
|
|
||||||
async function refreshHouseholdSelf() {
|
async function refreshHouseholdSelf() {
|
||||||
|
if (!auth.user.value) {
|
||||||
|
householdSelfRef.value = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const { data } = await api.households.getCurrentUserHousehold();
|
const { data } = await api.households.getCurrentUserHousehold();
|
||||||
householdSelfRef.value = data;
|
householdSelfRef.value = data;
|
||||||
|
|||||||
@@ -73,11 +73,11 @@ function createRecipeExplorerSearchState(groupSlug: ComputedRef<string>): Recipe
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Store references
|
// Store references
|
||||||
const categories = isOwnGroup ? useCategoryStore() : usePublicCategoryStore(groupSlug.value);
|
const categories = isOwnGroup.value ? useCategoryStore() : usePublicCategoryStore(groupSlug.value);
|
||||||
const foods = isOwnGroup ? useFoodStore() : usePublicFoodStore(groupSlug.value);
|
const foods = isOwnGroup.value ? useFoodStore() : usePublicFoodStore(groupSlug.value);
|
||||||
const households = isOwnGroup ? useHouseholdStore() : usePublicHouseholdStore(groupSlug.value);
|
const households = isOwnGroup.value ? useHouseholdStore() : usePublicHouseholdStore(groupSlug.value);
|
||||||
const tags = isOwnGroup ? useTagStore() : usePublicTagStore(groupSlug.value);
|
const tags = isOwnGroup.value ? useTagStore() : usePublicTagStore(groupSlug.value);
|
||||||
const tools = isOwnGroup ? useToolStore() : usePublicToolStore(groupSlug.value);
|
const tools = isOwnGroup.value ? useToolStore() : usePublicToolStore(groupSlug.value);
|
||||||
|
|
||||||
// Selected items
|
// Selected items
|
||||||
const selectedCategories = ref<NoUndefinedField<RecipeCategory>[]>([]);
|
const selectedCategories = ref<NoUndefinedField<RecipeCategory>[]>([]);
|
||||||
|
|||||||
Reference in New Issue
Block a user