mirror of
https://github.com/mealie-recipes/mealie.git
synced 2026-07-19 06:00:16 -04:00
fix: preserve deep link when redirecting to login (#7876)
This commit is contained in:
@@ -2,6 +2,7 @@ import { ref } from "vue";
|
||||
import { useAsyncKey } from "../use-utils";
|
||||
import { usePublicExploreApi } from "~/composables/api/api-client";
|
||||
import { useUserApi } from "~/composables/api";
|
||||
import { isSafeRedirectTarget } from "~/lib/validators/redirect";
|
||||
import type { OrderByNullPosition, Recipe } from "~/lib/api/types/recipe";
|
||||
import type { RecipeSearchQuery } from "~/lib/api/user/recipes/recipe";
|
||||
|
||||
@@ -43,6 +44,7 @@ function getParams(
|
||||
|
||||
export const useLazyRecipes = function (publicGroupSlug: string | null = null) {
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
// passing the group slug switches to using the public API
|
||||
const api = publicGroupSlug ? usePublicExploreApi(publicGroupSlug).explore : useUserApi();
|
||||
@@ -65,7 +67,8 @@ export const useLazyRecipes = function (publicGroupSlug: string | null = null) {
|
||||
);
|
||||
|
||||
if (error?.response?.status === 404) {
|
||||
router.push("/login");
|
||||
const redirect = typeof route.query.redirect === "string" ? route.query.redirect : undefined;
|
||||
router.push(isSafeRedirectTarget(redirect) ? { path: "/login", query: { redirect } } : "/login");
|
||||
}
|
||||
|
||||
return data ? data.items : [];
|
||||
|
||||
Reference in New Issue
Block a user