Vue composable identifying admin-only search results by route and kind to restrict regular user access.
// Source: https://github.com/metadist/synaplan | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import type { SearchResult } from './types'
/** System settings and Operate pages. A normal account cannot open them. */
export function isAdminOnlyResult(result: Pick<SearchResult, 'kind' | 'route'>): boolean {
if (result.kind === 'setting') return true
const path = (result.route ?? '').split(/[?#]/)[0]
return path === '/admin' || path.startsWith('/admin/')
}
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key