fix: #6263 remove reserved prefix (#7033)

This commit is contained in:
Zachary Schaffter
2026-02-14 13:05:42 -08:00
committed by GitHub
parent 5aafb56c4f
commit 904e6b7d82
55 changed files with 158 additions and 158 deletions

View File

@@ -41,8 +41,8 @@
export default defineNuxtComponent({ export default defineNuxtComponent({
setup() { setup() {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const groupSlug = computed(() => $auth.user.value?.groupSlug); const groupSlug = computed(() => auth.user.value?.groupSlug);
const { $globals } = useNuxtApp(); const { $globals } = useNuxtApp();
const sections = ref([ const sections = ref([

View File

@@ -73,11 +73,11 @@ import { useLoggedInState } from "~/composables/use-logged-in-state";
import type { ReadCookBook } from "~/lib/api/types/cookbook"; import type { ReadCookBook } from "~/lib/api/types/cookbook";
import CookbookEditor from "~/components/Domain/Cookbook/CookbookEditor.vue"; import CookbookEditor from "~/components/Domain/Cookbook/CookbookEditor.vue";
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const route = useRoute(); 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 { recipes, appendRecipes, assignSorted, removeRecipe, replaceRecipes } = useLazyRecipes(isOwnGroup.value ? null : groupSlug.value); const { recipes, appendRecipes, assignSorted, removeRecipe, replaceRecipes } = useLazyRecipes(isOwnGroup.value ? null : groupSlug.value);
const slug = route.params.slug as string; const slug = route.params.slug as string;
@@ -88,11 +88,11 @@ const router = useRouter();
const book = getOne(slug); const book = getOne(slug);
const isOwnHousehold = computed(() => { const isOwnHousehold = computed(() => {
if (!($auth.user.value && book.value?.householdId)) { if (!(auth.user.value && book.value?.householdId)) {
return false; return false;
} }
return $auth.user.value.householdId === book.value.householdId; return auth.user.value.householdId === book.value.householdId;
}); });
const canEdit = computed(() => isOwnGroup.value && isOwnHousehold.value); const canEdit = computed(() => isOwnGroup.value && isOwnHousehold.value);

View File

@@ -130,11 +130,11 @@ defineEmits<{
delete: [slug: string]; delete: [slug: string];
}>(); }>();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const route = useRoute(); const route = useRoute();
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
const showRecipeContent = computed(() => props.recipeId && props.slug); const showRecipeContent = computed(() => props.recipeId && props.slug);
const recipeRoute = computed<string>(() => { const recipeRoute = computed<string>(() => {
return showRecipeContent.value ? `/g/${groupSlug.value}/r/${props.slug}` : ""; return showRecipeContent.value ? `/g/${groupSlug.value}/r/${props.slug}` : "";

View File

@@ -160,11 +160,11 @@ defineEmits<{
delete: [slug: string]; delete: [slug: string];
}>(); }>();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const route = useRoute(); const route = useRoute();
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
const showRecipeContent = computed(() => props.recipeId && props.slug); const showRecipeContent = computed(() => props.recipeId && props.slug);
const recipeRoute = computed<string>(() => { const recipeRoute = computed<string>(() => {
return showRecipeContent.value ? `/g/${groupSlug.value}/r/${props.slug}` : ""; return showRecipeContent.value ? `/g/${groupSlug.value}/r/${props.slug}` : "";

View File

@@ -219,7 +219,7 @@ const EVENTS = {
shuffle: "shuffle", shuffle: "shuffle",
}; };
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $globals } = useNuxtApp(); const { $globals } = useNuxtApp();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const useMobileCards = computed(() => { const useMobileCards = computed(() => {
@@ -234,7 +234,7 @@ const sortLoading = ref(false);
const randomSeed = ref(Date.now().toString()); const randomSeed = ref(Date.now().toString());
const route = useRoute(); 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 page = ref(1); const page = ref(1);
const perPage = 32; const perPage = 32;

View File

@@ -202,13 +202,13 @@ const newMealdateString = computed(() => {
}); });
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $globals } = useNuxtApp(); const { $globals } = useNuxtApp();
const { household } = useHouseholdSelf(); const { household } = useHouseholdSelf();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const route = useRoute(); const route = useRoute();
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
const firstDayOfWeek = computed(() => { const firstDayOfWeek = computed(() => {
return household.value?.preferences?.firstDayOfWeek || 0; return household.value?.preferences?.firstDayOfWeek || 0;
@@ -296,12 +296,12 @@ const recipeRefWithScale = computed(() =>
); );
const isAdminAndNotOwner = computed(() => { const isAdminAndNotOwner = computed(() => {
return ( return (
$auth.user.value?.admin auth.user.value?.admin
&& $auth.user.value?.id !== recipeRef.value?.userId && auth.user.value?.id !== recipeRef.value?.userId
); );
}); });
const canDelete = computed(() => { const canDelete = computed(() => {
const user = $auth.user.value; const user = auth.user.value;
const recipe = recipeRef.value; const recipe = recipeRef.value;
return user && recipe && (user.admin || user.id === recipe.userId); return user && recipe && (user.admin || user.id === recipe.userId);
}); });

View File

@@ -110,8 +110,8 @@ defineEmits<{
const selected = defineModel<Recipe[]>({ default: () => [] }); const selected = defineModel<Recipe[]>({ default: () => [] });
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const groupSlug = $auth.user.value?.groupSlug; const groupSlug = auth.user.value?.groupSlug;
const router = useRouter(); const router = useRouter();
// Initialize sort state with default sorting by dateAdded descending // Initialize sort state with default sorting by dateAdded descending

View File

@@ -217,7 +217,7 @@ const props = withDefaults(defineProps<Props>(), {
const dialog = defineModel<boolean>({ default: false }); const dialog = defineModel<boolean>({ default: false });
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const api = useUserApi(); const api = useUserApi();
const preferences = useShoppingListPreferences(); const preferences = useShoppingListPreferences();
const ready = ref(false); const ready = ref(false);
@@ -239,9 +239,9 @@ const selectedShoppingList = ref<ShoppingListSummary | null>(null);
watch([dialog, () => preferences.value.viewAllLists], () => { watch([dialog, () => preferences.value.viewAllLists], () => {
if (dialog.value) { if (dialog.value) {
currentHouseholdSlug.value = $auth.user.value?.householdSlug || ""; currentHouseholdSlug.value = auth.user.value?.householdSlug || "";
filteredShoppingLists.value = props.shoppingLists.filter( filteredShoppingLists.value = props.shoppingLists.filter(
list => preferences.value.viewAllLists || list.userId === $auth.user.value?.id, list => preferences.value.viewAllLists || list.userId === auth.user.value?.id,
); );
if (filteredShoppingLists.value.length === 1 && !state.shoppingListShowAllToggled) { if (filteredShoppingLists.value.length === 1 && !state.shoppingListShowAllToggled) {

View File

@@ -87,7 +87,7 @@ const emit = defineEmits<{
selected: [recipe: RecipeSummary]; selected: [recipe: RecipeSummary];
}>(); }>();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const loading = ref(false); const loading = ref(false);
const selectedIndex = ref(-1); const selectedIndex = ref(-1);
@@ -153,7 +153,7 @@ watch(dialog, (val) => {
}); });
const route = useRoute(); 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 || "");
watch(route, close); watch(route, close);
function open() { function open() {

View File

@@ -119,10 +119,10 @@ whenever(
); );
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { household } = useHouseholdSelf(); const { household } = useHouseholdSelf();
const route = useRoute(); 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 firstDayOfWeek = computed(() => { const firstDayOfWeek = computed(() => {
return household.value?.preferences?.firstDayOfWeek || 0; return household.value?.preferences?.firstDayOfWeek || 0;

View File

@@ -34,11 +34,11 @@ import { useLazyRecipes } from "~/composables/recipes";
export default defineNuxtComponent({ export default defineNuxtComponent({
components: { RecipeCardSection, RecipeExplorerPageSearch }, components: { RecipeCardSection, RecipeExplorerPageSearch },
setup() { setup() {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); const route = useRoute();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
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 { recipes, appendRecipes, replaceRecipes } = useLazyRecipes(isOwnGroup.value ? null : groupSlug.value); const { recipes, appendRecipes, replaceRecipes } = useLazyRecipes(isOwnGroup.value ? null : groupSlug.value);

View File

@@ -141,13 +141,13 @@ const emit = defineEmits<{
ready: []; ready: [];
}>(); }>();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); const route = useRoute();
const { $globals } = useNuxtApp(); const { $globals } = useNuxtApp();
const i18n = useI18n(); const i18n = useI18n();
const showRandomLoading = ref(false); const showRandomLoading = ref(false);
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 { const {
state, state,

View File

@@ -81,11 +81,11 @@ import {
usePublicToolStore, usePublicToolStore,
} from "~/composables/store"; } from "~/composables/store";
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); const route = useRoute();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
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 { const {
state, state,

View File

@@ -52,14 +52,14 @@ const isFavorite = computed(() => {
async function toggleFavorite() { async function toggleFavorite() {
const api = useUserApi(); const api = useUserApi();
const $auth = useMealieAuth(); const auth = useMealieAuth();
if (!$auth.user.value) return; if (!auth.user.value) return;
if (!isFavorite.value) { if (!isFavorite.value) {
await api.users.addFavorite($auth.user.value?.id, props.recipeId); await api.users.addFavorite(auth.user.value?.id, props.recipeId);
} }
else { else {
await api.users.removeFavorite($auth.user.value?.id, props.recipeId); await api.users.removeFavorite(auth.user.value?.id, props.recipeId);
} }
await refreshUserRatings(); await refreshUserRatings();
} }

View File

@@ -354,8 +354,8 @@ async function createAssignFood() {
// Recipes // Recipes
const route = useRoute(); const route = useRoute();
const $auth = useMealieAuth(); const auth = useMealieAuth();
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 { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const api = isOwnGroup.value ? useUserApi() : usePublicExploreApi(groupSlug.value).explore; const api = isOwnGroup.value ? useUserApi() : usePublicExploreApi(groupSlug.value).explore;

View File

@@ -44,8 +44,8 @@ const props = withDefaults(defineProps<Props>(), {
scale: 1, scale: 1,
}); });
const route = useRoute(); const route = useRoute();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const groupSlug = computed(() => route.params.groupSlug || $auth.user?.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user?.value?.groupSlug || "");
const { useParsedIngredientText } = useIngredientTextParser(); const { useParsedIngredientText } = useIngredientTextParser();
const parsedIng = computed(() => { const parsedIng = computed(() => {

View File

@@ -159,7 +159,7 @@ const madeThisDialog = ref(false);
const userApi = useUserApi(); const userApi = useUserApi();
const { household } = useHouseholdSelf(); const { household } = useHouseholdSelf();
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const domMadeThisForm = ref<VForm>(); const domMadeThisForm = ref<VForm>();
const newTimelineEvent = ref<RecipeTimelineEventIn>({ const newTimelineEvent = ref<RecipeTimelineEventIn>({
subject: "", subject: "",
@@ -179,7 +179,7 @@ const newTimelineEventTimestampString = computed(() => {
const lastMade = ref(props.recipe.lastMade); const lastMade = ref(props.recipe.lastMade);
const lastMadeReady = ref(false); const lastMadeReady = ref(false);
onMounted(async () => { onMounted(async () => {
if (!$auth.user?.value?.householdSlug) { if (!auth.user?.value?.householdSlug) {
lastMade.value = props.recipe.lastMade; lastMade.value = props.recipe.lastMade;
} }
else { else {
@@ -255,8 +255,8 @@ async function createTimelineEvent() {
madeThisFormLoading.value = true; madeThisFormLoading.value = true;
newTimelineEvent.value.recipeId = props.recipe.id; newTimelineEvent.value.recipeId = props.recipe.id;
// Note: $auth.user is now a ref // Note: auth.user is now a ref
newTimelineEvent.value.subject = i18n.t("recipe.user-made-this", { user: $auth.user.value?.fullName }); newTimelineEvent.value.subject = i18n.t("recipe.user-made-this", { user: auth.user.value?.fullName });
// the user only selects the date, so we set the time to end of day local time // the user only selects the date, so we set the time to end of day local time
// we choose the end of day so it always comes after "new recipe" events // we choose the end of day so it always comes after "new recipe" events

View File

@@ -73,10 +73,10 @@ const props = withDefaults(defineProps<Props>(), {
disabled: false, disabled: false,
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { frac } = useFraction(); const { frac } = useFraction();
const route = useRoute(); const route = useRoute();
const groupSlug = computed(() => route.params.groupSlug || $auth.user?.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user?.value?.groupSlug || "");
const attrs = computed(() => { const attrs = computed(() => {
return props.small return props.small

View File

@@ -162,9 +162,9 @@ const state = reactive({
}, },
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); 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 || "");
// ================================================================= // =================================================================
// Context Menu // Context Menu

View File

@@ -220,11 +220,11 @@ import { useNavigationWarning } from "~/composables/use-navigation-warning";
const recipe = defineModel<NoUndefinedField<Recipe>>({ required: true }); const recipe = defineModel<NoUndefinedField<Recipe>>({ required: true });
const display = useDisplay(); const display = useDisplay();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); const route = useRoute();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
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 router = useRouter(); const router = useRouter();
const api = useUserApi(); const api = useUserApi();

View File

@@ -62,15 +62,15 @@ export default defineNuxtComponent({
error: false, error: false,
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { store: users } = useUserStore(); const { store: users } = useUserStore();
const user = computed(() => { const user = computed(() => {
return users.value.find(user => user.id === props.userId); return users.value.find(user => user.id === props.userId);
}); });
const imageURL = computed(() => { const imageURL = computed(() => {
// Note: $auth.user is a ref now // Note: auth.user is a ref now
const authUser = $auth.user.value; const authUser = auth.user.value;
const key = authUser?.cacheKey ?? ""; const key = authUser?.cacheKey ?? "";
return `/api/media/users/${props.userId}/profile.webp?cacheKey=${key}`; return `/api/media/users/${props.userId}/profile.webp?cacheKey=${key}`;
}); });

View File

@@ -102,9 +102,9 @@ export default defineNuxtComponent({
emits: ["update:modelValue"], emits: ["update:modelValue"],
setup(props, context) { setup(props, context) {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const isAdmin = computed(() => $auth.user.value?.admin); const isAdmin = computed(() => auth.user.value?.admin);
const token = ref(""); const token = ref("");
const selectedGroup = ref<string | null>(null); const selectedGroup = ref<string | null>(null);
const selectedHousehold = ref<string | null>(null); const selectedHousehold = ref<string | null>(null);

View File

@@ -106,11 +106,11 @@ export default defineNuxtComponent({
const i18n = useI18n(); const i18n = useI18n();
const { $appInfo, $globals } = useNuxtApp(); const { $appInfo, $globals } = useNuxtApp();
const display = useDisplay(); const display = useDisplay();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const route = useRoute(); 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 = useCookbookStore(i18n);
@@ -152,7 +152,7 @@ export default defineNuxtComponent({
}; };
} }
const currentUserHouseholdId = computed(() => $auth.user.value?.householdId); const currentUserHouseholdId = computed(() => auth.user.value?.householdId);
const cookbookLinks = computed<SideBarLink[]>(() => { const cookbookLinks = computed<SideBarLink[]>(() => {
if (!cookbooks.value?.length) { if (!cookbooks.value?.length) {
return []; return [];
@@ -187,7 +187,7 @@ export default defineNuxtComponent({
}); });
links.sort((a, b) => a.title.localeCompare(b.title)); links.sort((a, b) => a.title.localeCompare(b.title));
if ($auth.user.value && cookbookPreferences.value.hideOtherHouseholds) { if (auth.user.value && cookbookPreferences.value.hideOtherHouseholds) {
return ownLinks; return ownLinks;
} }
else { else {

View File

@@ -97,10 +97,10 @@ export default defineNuxtComponent({
}, },
}, },
setup() { setup() {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { loggedIn } = useLoggedInState(); const { loggedIn } = useLoggedInState();
const route = useRoute(); 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 { xs, smAndUp } = useDisplay(); const { xs, smAndUp } = useDisplay();
const routerLink = computed(() => groupSlug.value ? `/g/${groupSlug.value}` : "/"); const routerLink = computed(() => groupSlug.value ? `/g/${groupSlug.value}` : "/");
@@ -128,7 +128,7 @@ export default defineNuxtComponent({
async function logout() { async function logout() {
try { try {
await $auth.signOut("/login?direct=1"); await auth.signOut("/login?direct=1");
} }
catch (e) { catch (e) {
console.error(e); console.error(e);

View File

@@ -168,13 +168,13 @@ export default defineNuxtComponent({
}, },
emits: ["update:modelValue"], emits: ["update:modelValue"],
setup(props, context) { setup(props, context) {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { loggedIn, isOwnGroup } = useLoggedInState(); const { loggedIn, isOwnGroup } = useLoggedInState();
const isAdmin = computed(() => $auth.user.value?.admin); const isAdmin = computed(() => auth.user.value?.admin);
const canManage = computed(() => $auth.user.value?.canManage); const canManage = computed(() => auth.user.value?.canManage);
const userFavoritesLink = computed(() => $auth.user.value ? `/user/${$auth.user.value.id}/favorites` : undefined); const userFavoritesLink = computed(() => auth.user.value ? `/user/${auth.user.value.id}/favorites` : undefined);
const userProfileLink = computed(() => $auth.user.value ? "/user/profile" : undefined); const userProfileLink = computed(() => auth.user.value ? "/user/profile" : undefined);
const toggleDark = useToggleDarkMode(); const toggleDark = useToggleDarkMode();
@@ -217,7 +217,7 @@ export default defineNuxtComponent({
isAdmin, isAdmin,
canManage, canManage,
isOwnGroup, isOwnGroup,
sessionUser: $auth.user, sessionUser: auth.user,
toggleDark, toggleDark,
}; };
}, },

View File

@@ -9,9 +9,9 @@
*/ */
export default defineNuxtComponent({ export default defineNuxtComponent({
setup(_, ctx) { setup(_, ctx) {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const r = $auth.user.value?.advanced || false; const r = auth.user.value?.advanced || false;
return () => { return () => {
return r ? ctx.slots.default?.() : null; return r ? ctx.slots.default?.() : null;

View File

@@ -165,14 +165,14 @@ export function clearPageState(slug: string) {
} }
/** /**
* usePageUser provides a wrapper around $auth that provides a type-safe way to * usePageUser provides a wrapper around auth that provides a type-safe way to
* access the UserOut type from the context. If no user is logged in then an empty * access the UserOut type from the context. If no user is logged in then an empty
* object with all properties set to their zero value is returned. * object with all properties set to their zero value is returned.
*/ */
export function usePageUser(): { user: UserOut } { export function usePageUser(): { user: UserOut } {
const $auth = useMealieAuth(); const auth = useMealieAuth();
if (!$auth.user.value) { if (!auth.user.value) {
return { return {
user: { user: {
id: "", id: "",
@@ -188,5 +188,5 @@ export function usePageUser(): { user: UserOut } {
}; };
} }
return { user: $auth.user.value }; return { user: auth.user.value };
} }

View File

@@ -1,14 +1,14 @@
export const useLoggedInState = function () { export const useLoggedInState = function () {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); const route = useRoute();
const loggedIn = computed(() => $auth.loggedIn.value); const loggedIn = computed(() => auth.loggedIn.value);
const isOwnGroup = computed(() => { const isOwnGroup = computed(() => {
if (!route.params.groupSlug) { if (!route.params.groupSlug) {
return loggedIn.value; return loggedIn.value;
} }
else { else {
return loggedIn.value && $auth.user.value?.groupSlug === route.params.groupSlug; return loggedIn.value && auth.user.value?.groupSlug === route.params.groupSlug;
} }
}); });

View File

@@ -6,10 +6,10 @@ const loading = ref(false);
const ready = ref(false); const ready = ref(false);
export const useUserSelfRatings = function () { export const useUserSelfRatings = function () {
const $auth = useMealieAuth(); const auth = useMealieAuth();
async function refreshUserRatings() { async function refreshUserRatings() {
if (!$auth.user.value || loading.value) { if (!auth.user.value || loading.value) {
return; return;
} }
@@ -27,7 +27,7 @@ export const useUserSelfRatings = function () {
loading.value = true; loading.value = true;
const api = useUserApi(); const api = useUserApi();
const userId = $auth.user.value?.id || ""; const userId = auth.user.value?.id || "";
await api.users.setRating(userId, slug, rating, isFavorite); await api.users.setRating(userId, slug, rating, isFavorite);
loading.value = false; loading.value = false;

View File

@@ -64,7 +64,7 @@ export default defineNuxtComponent({
}); });
const i18n = useGlobalI18n(); const i18n = useGlobalI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $globals } = useNuxtApp(); const { $globals } = useNuxtApp();
const ready = ref(false); const ready = ref(false);
@@ -72,7 +72,7 @@ export default defineNuxtComponent({
const router = useRouter(); const router = useRouter();
async function insertGroupSlugIntoRoute() { async function insertGroupSlugIntoRoute() {
const groupSlug = ref($auth.user.value?.groupSlug); const groupSlug = ref(auth.user.value?.groupSlug);
if (!groupSlug.value) { if (!groupSlug.value) {
return; return;
} }

View File

@@ -163,9 +163,9 @@ export default defineNuxtComponent({
}); });
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); const route = useRoute();
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
const adminApi = useAdminApi(); const adminApi = useAdminApi();
const selected = ref(""); const selected = ref("");

View File

@@ -112,9 +112,9 @@ export default defineNuxtComponent({
const api = useAdminApi(); const api = useAdminApi();
const refUserDialog = ref(); const refUserDialog = ref();
const inviteDialog = ref(); const inviteDialog = ref();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const user = computed(() => $auth.user.value); const user = computed(() => auth.user.value);
const i18n = useI18n(); const i18n = useI18n();
const { $globals } = useNuxtApp(); const { $globals } = useNuxtApp();
@@ -149,7 +149,7 @@ export default defineNuxtComponent({
deleteUserMixin(id); deleteUserMixin(id);
if (isUserOwnAccount.value) { if (isUserOwnAccount.value) {
$auth.refresh(); auth.refresh();
} }
} }

View File

@@ -262,11 +262,11 @@ definePageMeta({
// ================================================================ // ================================================================
// Setup // Setup
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const userApi = useUserApi(); const userApi = useUserApi();
const adminApi = useAdminApi(); const adminApi = useAdminApi();
const groupSlug = computed(() => $auth.user.value?.groupSlug); const groupSlug = computed(() => auth.user.value?.groupSlug);
const { locale } = useLocales(); const { locale } = useLocales();
const router = useRouter(); const router = useRouter();
const isSubmitting = ref(false); const isSubmitting = ref(false);
@@ -347,9 +347,9 @@ const currentPage = ref(Pages.LANDING);
// Page Submission // Page Submission
async function updateUser() { async function updateUser() {
// Note: $auth.user is now a ref // Note: auth.user is now a ref
const { response } = await userApi.users.updateOne($auth.user.value!.id, { const { response } = await userApi.users.updateOne(auth.user.value!.id, {
...$auth.user.value, ...auth.user.value,
email: accountDetails.email.value, email: accountDetails.email.value,
username: accountDetails.username.value, username: accountDetails.username.value,
fullName: accountDetails.fullName.value, fullName: accountDetails.fullName.value,
@@ -360,7 +360,7 @@ async function updateUser() {
alert.error(i18n.t("events.something-went-wrong")); alert.error(i18n.t("events.something-went-wrong"));
} }
else { else {
$auth.refresh(); auth.refresh();
} }
} }
@@ -381,8 +381,8 @@ async function submitRegistration() {
} }
async function updateGroup() { async function updateGroup() {
// Note: $auth.user is now a ref // Note: auth.user is now a ref
const { data } = await userApi.groups.getOne($auth.user.value!.groupId); const { data } = await userApi.groups.getOne(auth.user.value!.groupId);
if (!data || !data.preferences) { if (!data || !data.preferences) {
alert.error(i18n.t("events.something-went-wrong")); alert.error(i18n.t("events.something-went-wrong"));
return; return;
@@ -398,16 +398,16 @@ async function updateGroup() {
preferences, preferences,
}; };
// Note: $auth.user is now a ref // Note: auth.user is now a ref
const { response } = await userApi.groups.updateOne($auth.user.value!.groupId, payload); const { response } = await userApi.groups.updateOne(auth.user.value!.groupId, payload);
if (!response || response.status !== 200) { if (!response || response.status !== 200) {
alert.error(i18n.t("events.something-went-wrong")); alert.error(i18n.t("events.something-went-wrong"));
} }
} }
async function updateHousehold() { async function updateHousehold() {
// Note: $auth.user is now a ref // Note: auth.user is now a ref
const { data } = await adminApi.households.getOne($auth.user.value!.householdId); const { data } = await adminApi.households.getOne(auth.user.value!.householdId);
if (!data || !data.preferences) { if (!data || !data.preferences) {
alert.error(i18n.t("events.something-went-wrong")); alert.error(i18n.t("events.something-went-wrong"));
return; return;
@@ -424,8 +424,8 @@ async function updateHousehold() {
preferences, preferences,
}; };
// Note: $auth.user is now a ref // Note: auth.user is now a ref
const { response } = await adminApi.households.updateOne($auth.user.value!.householdId, payload); const { response } = await adminApi.households.updateOne(auth.user.value!.householdId, payload);
if (!response || response.status !== 200) { if (!response || response.status !== 200) {
alert.error(i18n.t("events.something-went-wrong")); alert.error(i18n.t("events.something-went-wrong"));
} }

View File

@@ -159,7 +159,7 @@ export default defineNuxtComponent({
title: i18n.t("cookbook.cookbooks"), title: i18n.t("cookbook.cookbooks"),
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { store: allCookbooks, actions, updateAll } = useCookbookStore(); const { store: allCookbooks, actions, updateAll } = useCookbookStore();
// Make a local reactive copy of myCookbooks // Make a local reactive copy of myCookbooks
@@ -169,7 +169,7 @@ export default defineNuxtComponent({
(cookbooks) => { (cookbooks) => {
myCookbooks.value myCookbooks.value
= cookbooks?.filter( = cookbooks?.filter(
cookbook => cookbook.householdId === $auth.user.value?.householdId, cookbook => cookbook.householdId === auth.user.value?.householdId,
).sort((a, b) => a.position > b.position) ?? []; ).sort((a, b) => a.position > b.position) ?? [];
}, },
{ immediate: true }, { immediate: true },

View File

@@ -16,7 +16,7 @@ import { usePublicExploreApi } from "~/composables/api/api-client";
import { useRecipe } from "~/composables/recipes"; import { useRecipe } from "~/composables/recipes";
import type { Recipe } from "~/lib/api/types/recipe"; import type { Recipe } from "~/lib/api/types/recipe";
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const route = useRoute(); const route = useRoute();
const title = ref(route.meta?.title as string || ""); const title = ref(route.meta?.title as string || "");
@@ -34,7 +34,7 @@ function loadRecipe() {
} }
async function loadPublicRecipe() { async function loadPublicRecipe() {
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 api = usePublicExploreApi(groupSlug.value); const api = usePublicExploreApi(groupSlug.value);
const { data } = await useAsyncData(useAsyncKey(), async () => { const { data } = await useAsyncData(useAsyncKey(), async () => {
const { data, error } = await api.explore.recipes.getOne(slug); const { data, error } = await api.explore.recipes.getOne(slug);

View File

@@ -51,7 +51,7 @@ export default defineNuxtComponent({
middleware: ["group-only"], middleware: ["group-only"],
setup() { setup() {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $appInfo, $globals } = useNuxtApp(); const { $appInfo, $globals } = useNuxtApp();
useSeoMeta({ useSeoMeta({
@@ -99,7 +99,7 @@ export default defineNuxtComponent({
const route = useRoute(); const route = useRoute();
const router = useRouter(); const router = useRouter();
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
const subpage = computed({ const subpage = computed({
set(subpage: string) { set(subpage: string) {

View File

@@ -112,9 +112,9 @@ export default defineNuxtComponent({
loading: false, loading: false,
isEditJSON: false, isEditJSON: false,
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); 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 domUrlForm = ref<VForm | null>(null); const domUrlForm = ref<VForm | null>(null);
const api = useUserApi(); const api = useUserApi();

View File

@@ -53,9 +53,9 @@ export default defineNuxtComponent({
error: false, error: false,
loading: false, loading: false,
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); 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 api = useUserApi(); const api = useUserApi();
const router = useRouter(); const router = useRouter();

View File

@@ -144,10 +144,10 @@ export default defineNuxtComponent({
loading: false, loading: false,
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const api = useUserApi(); const api = useUserApi();
const route = useRoute(); 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 router = useRouter(); const router = useRouter();
const tags = useTagStore(); const tags = useTagStore();

View File

@@ -47,9 +47,9 @@ export default defineNuxtComponent({
const state = reactive({ const state = reactive({
loading: false, loading: false,
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); 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 api = useUserApi(); const api = useUserApi();
const router = useRouter(); const router = useRouter();

View File

@@ -436,7 +436,7 @@ export default defineNuxtComponent({
setup() { setup() {
const display = useDisplay(); const display = useDisplay();
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); const route = useRoute();
useSeoMeta({ useSeoMeta({
@@ -445,7 +445,7 @@ export default defineNuxtComponent({
const useMobile = computed(() => display.smAndDown.value); const useMobile = computed(() => display.smAndDown.value);
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 { isOwnGroup } = useLoggedInState(); const { isOwnGroup } = useLoggedInState();
const api = isOwnGroup.value ? useUserApi() : usePublicExploreApi(groupSlug.value).explore; const api = isOwnGroup.value ? useUserApi() : usePublicExploreApi(groupSlug.value).explore;

View File

@@ -30,7 +30,7 @@ export default defineNuxtComponent({
}, },
middleware: ["group-only"], middleware: ["group-only"],
setup() { setup() {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const toolStore = useToolStore(); const toolStore = useToolStore();
const dialog = ref(false); const dialog = ref(false);
const i18n = useI18n(); const i18n = useI18n();
@@ -39,7 +39,7 @@ export default defineNuxtComponent({
title: i18n.t("tool.tools"), title: i18n.t("tool.tools"),
}); });
const userHousehold = computed(() => $auth.user.value?.householdSlug || ""); const userHousehold = computed(() => auth.user.value?.householdSlug || "");
const tools = computed(() => toolStore.store.value.map(tool => ( const tools = computed(() => toolStore.store.value.map(tool => (
{ {
...tool, ...tool,

View File

@@ -17,9 +17,9 @@ definePageMeta({
layout: "basic", layout: "basic",
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const route = useRoute(); 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 router = useRouter(); const router = useRouter();
const recipeId = route.params.id as string; const recipeId = route.params.id as string;

View File

@@ -371,7 +371,7 @@ export default defineNuxtComponent({
setup() { setup() {
const userApi = useUserApi(); const userApi = useUserApi();
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const tableConfig = { const tableConfig = {
hideColumns: true, hideColumns: true,
canExport: true, canExport: true,
@@ -424,7 +424,7 @@ export default defineNuxtComponent({
}, },
]; ];
const userHousehold = computed(() => $auth.user.value?.householdSlug || ""); const userHousehold = computed(() => auth.user.value?.householdSlug || "");
const foodStore = useFoodStore(); const foodStore = useFoodStore();
const foods = computed(() => foodStore.store.value.map((food) => { const foods = computed(() => foodStore.store.value.map((food) => {
const onHand = food.householdsWithIngredientFood?.includes(userHousehold.value) || false; const onHand = food.householdsWithIngredientFood?.includes(userHousehold.value) || false;

View File

@@ -254,14 +254,14 @@ export default defineNuxtComponent({
scrollToTop: true, scrollToTop: true,
setup() { setup() {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $globals } = useNuxtApp(); const { $globals } = useNuxtApp();
useSeoMeta({ useSeoMeta({
title: i18n.t("data-pages.recipes.recipe-data"), title: i18n.t("data-pages.recipes.recipe-data"),
}); });
const { getAllRecipes, refreshRecipes } = useRecipes(true, true, false, `householdId=${$auth.user.value?.householdId || ""}`); const { getAllRecipes, refreshRecipes } = useRecipes(true, true, false, `householdId=${auth.user.value?.householdId || ""}`);
const selected = ref<Recipe[]>([]); const selected = ref<Recipe[]>([]);
function resetAll() { function resetAll() {

View File

@@ -143,7 +143,7 @@ interface RecipeToolWithOnHand extends RecipeTool {
export default defineNuxtComponent({ export default defineNuxtComponent({
setup() { setup() {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const tableConfig = { const tableConfig = {
hideColumns: true, hideColumns: true,
canExport: true, canExport: true,
@@ -175,7 +175,7 @@ export default defineNuxtComponent({
bulkDeleteDialog: false, bulkDeleteDialog: false,
}); });
const userHousehold = computed(() => $auth.user.value?.householdSlug || ""); const userHousehold = computed(() => auth.user.value?.householdSlug || "");
const toolData = useToolData(); const toolData = useToolData();
const toolStore = useToolStore(); const toolStore = useToolStore();
const tools = computed(() => toolStore.store.value.map((tools) => { const tools = computed(() => toolStore.store.value.map((tools) => {

View File

@@ -263,7 +263,7 @@ export default defineNuxtComponent({
}, },
setup(props) { setup(props) {
const api = useUserApi(); const api = useUserApi();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { household } = useHouseholdSelf(); const { household } = useHouseholdSelf();
const requiredRule = (value: any) => !!value || "Required."; const requiredRule = (value: any) => !!value || "Required.";
@@ -343,7 +343,7 @@ export default defineNuxtComponent({
existing: false, existing: false,
id: 0, id: 0,
groupId: "", groupId: "",
userId: $auth.user.value?.id || "", userId: auth.user.value?.id || "",
}); });
const newMealDateString = computed(() => { const newMealDateString = computed(() => {
@@ -375,7 +375,7 @@ export default defineNuxtComponent({
newMeal.existing = true; newMeal.existing = true;
newMeal.id = id; newMeal.id = id;
newMeal.groupId = groupId; newMeal.groupId = groupId;
newMeal.userId = userId || $auth.user.value?.id || ""; newMeal.userId = userId || auth.user.value?.id || "";
state.value.dialog = true; state.value.dialog = true;
dialog.note = !recipeId; dialog.note = !recipeId;

View File

@@ -125,7 +125,7 @@ export default defineNuxtComponent({
UserAvatar, UserAvatar,
}, },
setup() { setup() {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const api = useUserApi(); const api = useUserApi();
const i18n = useI18n(); const i18n = useI18n();
@@ -169,7 +169,7 @@ export default defineNuxtComponent({
await refreshMembers(); await refreshMembers();
}); });
return { members, headers, setPermissions, sessionUser: $auth.user }; return { members, headers, setPermissions, sessionUser: auth.user };
}, },
}); });
</script> </script>

View File

@@ -14,12 +14,12 @@ export default defineNuxtComponent({
layout: "blank", layout: "blank",
}); });
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $axios } = useNuxtApp(); const { $axios } = useNuxtApp();
const router = useRouter(); const router = useRouter();
const activityPreferences = useUserActivityPreferences(); const activityPreferences = useUserActivityPreferences();
const { getDefaultActivityRoute } = useDefaultActivity(); const { getDefaultActivityRoute } = useDefaultActivity();
const groupSlug = computed(() => $auth.user.value?.groupSlug); const groupSlug = computed(() => auth.user.value?.groupSlug);
async function redirectPublicUserToDefaultGroup() { async function redirectPublicUserToDefaultGroup() {
const { data } = await $axios.get<AppInfo>("/api/app/about"); const { data } = await $axios.get<AppInfo>("/api/app/about");
@@ -40,7 +40,7 @@ export default defineNuxtComponent({
activityPreferences.value.defaultActivity, activityPreferences.value.defaultActivity,
groupSlug.value, groupSlug.value,
); );
if (!isDemo && isFirstLogin && $auth.user.value?.admin) { if (!isDemo && isFirstLogin && auth.user.value?.admin) {
router.push("/admin/setup"); router.push("/admin/setup");
} }
else if (defaultActivityRoute) { else if (defaultActivityRoute) {

View File

@@ -228,10 +228,10 @@ export default defineNuxtComponent({
const router = useRouter(); const router = useRouter();
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $appInfo, $axios } = useNuxtApp(); const { $appInfo, $axios } = useNuxtApp();
const { loggedIn } = useLoggedInState(); const { loggedIn } = useLoggedInState();
const groupSlug = computed(() => $auth.user.value?.groupSlug); const groupSlug = computed(() => auth.user.value?.groupSlug);
const isDemo = ref(false); const isDemo = ref(false);
const isFirstLogin = ref(false); const isFirstLogin = ref(false);
const activityPreferences = useUserActivityPreferences(); const activityPreferences = useUserActivityPreferences();
@@ -265,7 +265,7 @@ export default defineNuxtComponent({
activityPreferences.value.defaultActivity, activityPreferences.value.defaultActivity,
groupSlug.value, groupSlug.value,
); );
if (!isDemo.value && isFirstLogin.value && $auth.user.value?.admin) { if (!isDemo.value && isFirstLogin.value && auth.user.value?.admin) {
router.push("/admin/setup"); router.push("/admin/setup");
} }
else if (defaultActivityRoute) { else if (defaultActivityRoute) {
@@ -284,7 +284,7 @@ export default defineNuxtComponent({
const { passwordIcon, inputType, togglePasswordShow } = usePasswordField(); const { passwordIcon, inputType, togglePasswordShow } = usePasswordField();
whenever( whenever(
() => $appInfo.enableOidc && $appInfo.oidcRedirect && !isCallback() && !isDirectLogin() /* && !$auth.check().valid */, () => $appInfo.enableOidc && $appInfo.oidcRedirect && !isCallback() && !isDirectLogin() /* && !auth.check().valid */,
() => oidcAuthenticate(), () => oidcAuthenticate(),
{ immediate: true }, { immediate: true },
); );
@@ -309,7 +309,7 @@ export default defineNuxtComponent({
if (callback) { if (callback) {
oidcLoggingIn.value = true; oidcLoggingIn.value = true;
try { try {
await $auth.oauthSignIn(); await auth.oauthSignIn();
} }
catch (error) { catch (error) {
await router.replace("/login?direct=1"); await router.replace("/login?direct=1");
@@ -335,7 +335,7 @@ export default defineNuxtComponent({
formData.append("remember_me", String(form.remember)); formData.append("remember_me", String(form.remember));
try { try {
await $auth.signIn(formData); await auth.signIn(formData);
} }
catch (error) { catch (error) {
console.log(error); console.log(error);

View File

@@ -353,7 +353,7 @@ export default defineNuxtComponent({
setup() { setup() {
const { mdAndUp } = useDisplay(); const { mdAndUp } = useDisplay();
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const preferences = useShoppingListPreferences(); const preferences = useShoppingListPreferences();
useSeoMeta({ useSeoMeta({
@@ -361,7 +361,7 @@ export default defineNuxtComponent({
}); });
const route = useRoute(); 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 id = route.params.id as string; const id = route.params.id as string;
const shoppingListPage = useShoppingListPage(id); const shoppingListPage = useShoppingListPage(id);

View File

@@ -132,7 +132,7 @@ import type { UserOut } from "~/lib/api/types/user";
export default defineNuxtComponent({ export default defineNuxtComponent({
setup() { setup() {
const $auth = useMealieAuth(); const auth = useMealieAuth();
const i18n = useI18n(); const i18n = useI18n();
const ready = ref(false); const ready = ref(false);
const userApi = useUserApi(); const userApi = useUserApi();
@@ -142,7 +142,7 @@ export default defineNuxtComponent({
title: i18n.t("shopping-list.shopping-list"), title: i18n.t("shopping-list.shopping-list"),
}); });
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
const overrideDisableRedirect = ref(false); const overrideDisableRedirect = ref(false);
const disableRedirect = computed(() => route.query.disableRedirect === "true" || overrideDisableRedirect.value); const disableRedirect = computed(() => route.query.disableRedirect === "true" || overrideDisableRedirect.value);
const preferences = useShoppingListPreferences(); const preferences = useShoppingListPreferences();
@@ -165,7 +165,7 @@ export default defineNuxtComponent({
return []; return [];
} }
return shoppingLists.value.filter(list => preferences.value.viewAllLists || list.userId === $auth.user.value?.id); return shoppingLists.value.filter(list => preferences.value.viewAllLists || list.userId === auth.user.value?.id);
}); });
// This has to appear before the shoppingListChoices watcher, otherwise that runs first and the redirect is not disabled // This has to appear before the shoppingListChoices watcher, otherwise that runs first and the redirect is not disabled

View File

@@ -114,14 +114,14 @@ export default defineNuxtComponent({
middleware: ["advanced-only"], middleware: ["advanced-only"],
setup() { setup() {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
useSeoMeta({ useSeoMeta({
title: i18n.t("settings.token.api-tokens"), title: i18n.t("settings.token.api-tokens"),
}); });
const user = computed(() => { const user = computed(() => {
return $auth.user.value; return auth.user.value;
}); });
const api = useUserApi(); const api = useUserApi();
@@ -136,7 +136,7 @@ export default defineNuxtComponent({
createdToken.value = ""; createdToken.value = "";
loading.value = false; loading.value = false;
name.value = ""; name.value = "";
$auth.refresh(); auth.refresh();
} }
async function createToken(name: string) { async function createToken(name: string) {
@@ -161,7 +161,7 @@ export default defineNuxtComponent({
async function deleteToken(id: number) { async function deleteToken(id: number) {
const { data } = await api.users.deleteAPIToken(id); const { data } = await api.users.deleteAPIToken(id);
$auth.refresh(); auth.refresh();
return data; return data;
} }

View File

@@ -13,7 +13,7 @@
file-name="profile" file-name="profile"
accept="image/*" accept="image/*"
:url="`/api/users/${userCopy.id}/image`" :url="`/api/users/${userCopy.id}/image`"
@uploaded="$auth.refresh()" @uploaded="auth.refresh()"
/> />
</div> </div>
</template> </template>
@@ -231,9 +231,9 @@ export default defineNuxtComponent({
}, },
setup() { setup() {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { getDefaultActivityLabels, getActivityLabel, getActivityKey } = useDefaultActivity(); const { getDefaultActivityLabels, getActivityLabel, getActivityKey } = useDefaultActivity();
const user = computed(() => $auth.user.value); const user = computed(() => auth.user.value);
useSeoMeta({ useSeoMeta({
title: i18n.t("settings.profile"), title: i18n.t("settings.profile"),
@@ -267,7 +267,7 @@ export default defineNuxtComponent({
if (!userCopy.value?.id) return; if (!userCopy.value?.id) return;
const { response } = await api.users.updateOne(userCopy.value.id, userCopy.value); const { response } = await api.users.updateOne(userCopy.value.id, userCopy.value);
if (response?.status === 200) { if (response?.status === 200) {
$auth.refresh(); auth.refresh();
} }
} }
@@ -303,7 +303,7 @@ export default defineNuxtComponent({
domUpdatePassword, domUpdatePassword,
passwordsMatch, passwordsMatch,
validators, validators,
$auth, auth,
}; };
}, },
}); });

View File

@@ -294,17 +294,17 @@ export default defineNuxtComponent({
scrollToTop: true, scrollToTop: true,
async setup() { async setup() {
const i18n = useI18n(); const i18n = useI18n();
const $auth = useMealieAuth(); const auth = useMealieAuth();
const { $appInfo } = useNuxtApp(); const { $appInfo } = useNuxtApp();
const route = useRoute(); const route = useRoute();
const groupSlug = computed(() => route.params.groupSlug || $auth.user.value?.groupSlug || ""); const groupSlug = computed(() => route.params.groupSlug || auth.user.value?.groupSlug || "");
useSeoMeta({ useSeoMeta({
title: i18n.t("settings.profile"), title: i18n.t("settings.profile"),
}); });
const user = computed<UserOut | null>(() => { const user = computed<UserOut | null>(() => {
const authUser = $auth.user.value; const authUser = auth.user.value;
if (!authUser) return null; if (!authUser) return null;
// Override canInvite if password login is disabled // Override canInvite if password login is disabled