mirror of
				https://github.com/mealie-recipes/mealie.git
				synced 2025-10-31 10:13:32 -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:
		| @@ -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("/") | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user