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:
Kuchenpirat 2024-01-14 17:03:31 +01:00 committed by GitHub
parent 43958527f4
commit 030588e5bb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -34,7 +34,7 @@ import { SidebarLinks } from "~/types/application-types";
export default defineComponent({
components: { AppHeader, AppSidebar, TheSnackbar },
middleware: "auth",
middleware: ["auth", "admin-only"],
auth: true,
setup() {
const { $globals, i18n, $vuetify } = useContext();

View 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("/")
}
}