mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
manage-data pages
This commit is contained in:
parent
02997cd36e
commit
19e776a772
@ -1,8 +1,8 @@
|
|||||||
interface AuthRedirectParams {
|
interface AdminRedirectParams {
|
||||||
$auth: any
|
$auth: any
|
||||||
redirect: (path: string) => void
|
redirect: (path: string) => void
|
||||||
}
|
}
|
||||||
export default function ({ $auth, redirect }: AuthRedirectParams) {
|
export default function ({ $auth, redirect }: AdminRedirectParams) {
|
||||||
// If the user is not an admin redirect to the home page
|
// If the user is not an admin redirect to the home page
|
||||||
if (!$auth.user.admin) {
|
if (!$auth.user.admin) {
|
||||||
return redirect("/")
|
return redirect("/")
|
||||||
|
12
frontend/middleware/can-organize-only.ts
Normal file
12
frontend/middleware/can-organize-only.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
interface CanOrganizeRedirectParams {
|
||||||
|
$auth: any
|
||||||
|
redirect: (path: string) => void
|
||||||
|
}
|
||||||
|
export default function ({ $auth, redirect }: CanOrganizeRedirectParams) {
|
||||||
|
console.log($auth.user);
|
||||||
|
// If the user is not allowed to organize redirect to the home page
|
||||||
|
if (!$auth.user.canOrganize) {
|
||||||
|
console.warn("User is not allowed to organize data");
|
||||||
|
return redirect("/")
|
||||||
|
}
|
||||||
|
}
|
@ -73,6 +73,7 @@ import { useCategoryStore, useCategoryData } from "~/composables/store";
|
|||||||
import { RecipeCategory } from "~/lib/api/types/admin";
|
import { RecipeCategory } from "~/lib/api/types/admin";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
middleware: ["auth", "can-organize-only"],
|
||||||
setup() {
|
setup() {
|
||||||
const { i18n } = useContext();
|
const { i18n } = useContext();
|
||||||
const tableConfig = {
|
const tableConfig = {
|
||||||
|
@ -201,8 +201,8 @@ import { useFoodStore, useLabelStore } from "~/composables/store";
|
|||||||
import { VForm } from "~/types/vuetify";
|
import { VForm } from "~/types/vuetify";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
|
||||||
components: { MultiPurposeLabel, RecipeDataAliasManagerDialog },
|
components: { MultiPurposeLabel, RecipeDataAliasManagerDialog },
|
||||||
|
middleware: ["auth", "can-organize-only"],
|
||||||
setup() {
|
setup() {
|
||||||
const userApi = useUserApi();
|
const userApi = useUserApi();
|
||||||
const { i18n } = useContext();
|
const { i18n } = useContext();
|
||||||
|
@ -122,6 +122,7 @@ import { useLabelData, useLabelStore } from "~/composables/store";
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { MultiPurposeLabel },
|
components: { MultiPurposeLabel },
|
||||||
|
middleware: ["auth", "can-organize-only"],
|
||||||
setup() {
|
setup() {
|
||||||
const userApi = useUserApi();
|
const userApi = useUserApi();
|
||||||
const { i18n } = useContext();
|
const { i18n } = useContext();
|
||||||
|
@ -176,6 +176,7 @@ enum MODES {
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { RecipeDataTable, RecipeOrganizerSelector, GroupExportData, RecipeSettingsSwitches },
|
components: { RecipeDataTable, RecipeOrganizerSelector, GroupExportData, RecipeSettingsSwitches },
|
||||||
|
middleware: ["auth", "can-organize-only"],
|
||||||
scrollToTop: true,
|
scrollToTop: true,
|
||||||
setup() {
|
setup() {
|
||||||
const { getAllRecipes, refreshRecipes } = useRecipes(true, true);
|
const { getAllRecipes, refreshRecipes } = useRecipes(true, true);
|
||||||
|
@ -73,6 +73,7 @@ import { useTagStore, useTagData } from "~/composables/store";
|
|||||||
import { RecipeTag } from "~/lib/api/types/admin";
|
import { RecipeTag } from "~/lib/api/types/admin";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
middleware: ["auth", "can-organize-only"],
|
||||||
setup() {
|
setup() {
|
||||||
const { i18n } = useContext();
|
const { i18n } = useContext();
|
||||||
const tableConfig = {
|
const tableConfig = {
|
||||||
|
@ -80,6 +80,7 @@ import { useToolStore, useToolData } from "~/composables/store";
|
|||||||
import { RecipeTool } from "~/lib/api/types/admin";
|
import { RecipeTool } from "~/lib/api/types/admin";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
|
middleware: ["auth", "can-organize-only"],
|
||||||
setup() {
|
setup() {
|
||||||
const { i18n } = useContext();
|
const { i18n } = useContext();
|
||||||
const tableConfig = {
|
const tableConfig = {
|
||||||
|
@ -218,6 +218,7 @@ import { VForm } from "~/types/vuetify";
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { RecipeDataAliasManagerDialog },
|
components: { RecipeDataAliasManagerDialog },
|
||||||
|
middleware: ["auth", "can-organize-only"],
|
||||||
setup() {
|
setup() {
|
||||||
const userApi = useUserApi();
|
const userApi = useUserApi();
|
||||||
const { i18n } = useContext();
|
const { i18n } = useContext();
|
||||||
|
@ -162,17 +162,16 @@
|
|||||||
</UserProfileLinkCard>
|
</UserProfileLinkCard>
|
||||||
</v-col>
|
</v-col>
|
||||||
</AdvancedOnly>
|
</AdvancedOnly>
|
||||||
<AdvancedOnly>
|
<!-- $auth.user.canOrganize should not be null because of the auth middleware -->
|
||||||
<v-col cols="12" sm="12" md="6">
|
<v-col v-if="$auth.user.canOrganize" cols="12" sm="12" md="6">
|
||||||
<UserProfileLinkCard
|
<UserProfileLinkCard
|
||||||
:link="{ text: $tc('profile.manage-data'), to: `/group/data/foods` }"
|
:link="{ text: $tc('profile.manage-data'), to: `/group/data/foods` }"
|
||||||
:image="require('~/static/svgs/manage-recipes.svg')"
|
:image="require('~/static/svgs/manage-recipes.svg')"
|
||||||
>
|
>
|
||||||
<template #title> {{ $t('profile.manage-data') }} </template>
|
<template #title> {{ $t('profile.manage-data') }} </template>
|
||||||
{{ $t('profile.manage-data-description') }}
|
{{ $t('profile.manage-data-description') }}
|
||||||
</UserProfileLinkCard>
|
</UserProfileLinkCard>
|
||||||
</v-col>
|
</v-col>
|
||||||
</AdvancedOnly>
|
|
||||||
<AdvancedOnly>
|
<AdvancedOnly>
|
||||||
<v-col cols="12" sm="12" md="6">
|
<v-col cols="12" sm="12" md="6">
|
||||||
<UserProfileLinkCard
|
<UserProfileLinkCard
|
||||||
@ -208,6 +207,7 @@ export default defineComponent({
|
|||||||
UserAvatar,
|
UserAvatar,
|
||||||
StatsCards,
|
StatsCards,
|
||||||
},
|
},
|
||||||
|
middleware: ["auth"],
|
||||||
scrollToTop: true,
|
scrollToTop: true,
|
||||||
setup() {
|
setup() {
|
||||||
const { $auth, i18n } = useContext();
|
const { $auth, i18n } = useContext();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user