Optimize permission
This commit is contained in:
@@ -2,13 +2,13 @@ import { PropsWithChildren } from 'react'
|
||||
import { hasPathPermission, hasPermission } from '@/util/auth'
|
||||
|
||||
interface PermissionProps extends PropsWithChildren {
|
||||
operationCode?: string
|
||||
operationCode?: string[]
|
||||
path?: string
|
||||
}
|
||||
|
||||
const Permission = (props: PermissionProps) => {
|
||||
if (
|
||||
(!props.operationCode || hasPermission(props.operationCode)) &&
|
||||
(!props.operationCode || props.operationCode.some(hasPermission)) &&
|
||||
(!props.path || hasPathPermission(props.path))
|
||||
) {
|
||||
return props.children
|
||||
|
||||
Reference in New Issue
Block a user