mirror of
https://github.com/mealie-recipes/mealie.git
synced 2025-07-09 03:04:54 -04:00
fix admin pages accessible by non admin users (#2988)
Co-authored-by: Michael Genson <71845777+michael-genson@users.noreply.github.com>
This commit is contained in:
parent
43958527f4
commit
030588e5bb
@ -34,7 +34,7 @@ import { SidebarLinks } from "~/types/application-types";
|
|||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: { AppHeader, AppSidebar, TheSnackbar },
|
components: { AppHeader, AppSidebar, TheSnackbar },
|
||||||
middleware: "auth",
|
middleware: ["auth", "admin-only"],
|
||||||
auth: true,
|
auth: true,
|
||||||
setup() {
|
setup() {
|
||||||
const { $globals, i18n, $vuetify } = useContext();
|
const { $globals, i18n, $vuetify } = useContext();
|
||||||
|
10
frontend/middleware/admin-only.ts
Normal file
10
frontend/middleware/admin-only.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
interface AuthRedirectParams {
|
||||||
|
$auth: any
|
||||||
|
redirect: (path: string) => void
|
||||||
|
}
|
||||||
|
export default function ({ $auth, redirect }: AuthRedirectParams) {
|
||||||
|
// If the user is not an admin redirect to the home page
|
||||||
|
if (!$auth.user.admin) {
|
||||||
|
return redirect("/")
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user