Merge manager tools into main cabinet
This commit is contained in:
13
app/middleware/manager-only.ts
Normal file
13
app/middleware/manager-only.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { MeDocument } from '~/composables/graphql/generated';
|
||||
|
||||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const { client } = useApolloClient('default');
|
||||
const response = await client.query({
|
||||
query: MeDocument,
|
||||
fetchPolicy: 'cache-first',
|
||||
});
|
||||
|
||||
if (response.data.me?.role !== 'MANAGER') {
|
||||
return navigateTo('/');
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user