Hooks
Functions
useAuthority
useAuthority hook help to check whether the current user has permmision to access.
Example
import useAuthority from '@/utils/hooks/useAuthority'
const Component = () => {
const { userAuthority = [], authority = [], children } = props
const userAuthority = ['USER']
const authority = ['ADMIN', 'USER']
const roleMatched = useAuthority(userAuthority, authority)
return (...)
}
Params
| param | Description | Type | Default |
|---|---|---|---|
| userAuthority | List of the user roles | Array | [] |
| authority | List of roles that allow to access | Array | [] |
Return
| return | Description | Type | Default |
|---|---|---|---|
| roleMatched | Result of authority match | boolean | - |