671979e012
* Add server management menu item * Server Management Page & Settings Dialog * escape from the precommits hooks * Add Delete User Dialog * Add invitations page * Add Projects Page * Pulling in GraphQL Data * Settings Mutations * Fix cardinfo type * GraphQL in Active Users * Add icons * Infinite Load on Active Users * Tidy Ups * TS fixes * Add Update button functionality * Add Delete User * Projects * Home Done * New query * Delete User * WIP User Roles * Overflow fix * Table Update * Add Onclick to rows * Fix bugs * Fix console error * Admin Middleware * Role Update Dialog * TS Fixes * Latest updates * Tidyups * Tidy Up Nav Menu * Tidy Up Card * ChangeUserRoleDialog Tidyup * Fix bubbling issue on Table * Design fixes * fix: speckle server version hydration mismatch * Remove Dialog bg-white * Rename Query, Fix Export * fix: allowing FormSelectBase to reject updates * feat: cache policies for new admin graph fields * feat: cache updates so no refetch necessary * PR Changes * Fix Projects Page * Updates to Roles * Project Delete Mutation * Add Resend & Delete Invite Mutation * Fix console warnings * Disable active user role select * Linting fixes * Reorder * Linting fixes * Changes from PR * Fixes from PR * Ui Fixes * Update Settings Dialog Cache on Save * Fix colours * Delete Invitation Mutation Moved * Delete Project Logic moved * Delete Mutation moved to component * Change User Role mutation moved to Dialog * Reorder * WIP - Checkbox Bug * attempted checkbox fix * Update Caching * Rollback tsc * Update to Resend Button * Add new buttons * Use defineModel * Re-add emits * Move mutation * serverInfo cache update fix * fixed delete invite cache update * Updates to Project Delete Dialog Caching * Remove unneeded props * Fix caching in DeleteUserDialog * Improved error handling in server info update * Swap Invite modal to new style * updated evictObjectFields details * Update cache on successfull invite * Add Invite dialog * Add project Dialog Update * defineModel * Remove emits from Add Project and Invites * Add missing Dialog * Updates from PR * Adjust query * Remove need for items in admin data query --------- Co-authored-by: Kristaps Fabians Geikins <fabis94@live.com>
29 lines
824 B
TypeScript
29 lines
824 B
TypeScript
import { activeUserQuery } from '~~/lib/auth/composables/activeUser'
|
|
import { useApolloClientFromNuxt } from '~~/lib/common/composables/graphql'
|
|
import { convertThrowIntoFetchResult } from '~~/lib/common/helpers/graphql'
|
|
import { Roles } from '@speckle/shared'
|
|
|
|
/**
|
|
* Apply this to a page to prevent access by non-admin users
|
|
*/
|
|
export default defineNuxtRouteMiddleware(async () => {
|
|
const client = useApolloClientFromNuxt()
|
|
|
|
const { data } = await client
|
|
.query({
|
|
query: activeUserQuery
|
|
})
|
|
.catch(convertThrowIntoFetchResult)
|
|
|
|
// If user is not an Admin, show 403 message.
|
|
if (data?.activeUser?.role !== Roles.Server.Admin) {
|
|
return abortNavigation(
|
|
createError({
|
|
statusCode: 403,
|
|
message: 'You do not have access to this page'
|
|
})
|
|
)
|
|
}
|
|
return undefined
|
|
})
|