
Security News
High Salaries No Longer Enough to Attract Top Cybersecurity Talent
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
@availity/authorize
Advanced tools
Check user permissions to see if the current user is authorized to see your content.
Check user permissions to see if the current user is authorized to see your content.
npm install @availity/authorize @availity/api-axios @availity/api-core axios --save
import React from 'react';
import Authorize from '@availity/authorize';
// ...
<Authorize permissions="1234">
{/* stuff to render if the user is authorized with permission indicated above */}
</Authorize>
// ...
Component which validates the user's permissions to determine if they should be able to see the children content.
permissions
: String, number, or an array containing strings/numbers or an array containing strings/numbers. Required.
'1234'
['1234', '2345', ['3456', '4567'], ['5678', '6789']]
. The items in deep/nested array indicate permission IDs which must all be granted to the user to be consider authorized, they act as "and". The items in the top array act as 'or', if any are granted to the user the user would be consider authorized. The example ['1234', '2345', ['3456', '4567'], ['5678', '6789']]
would be similar '1234' || '2345' || ('3456' && '4567') || ('5678' && '6789')
loader
: Boolean or node. Optional, default: true
. When true
, BlockUi
will be used when loading the permissions. When a node
, that node will be render instead of BlockUi
when loading the permissions. When false
, nothing will be render when loading the permissions.organizationId
: String. Optional, when present, the permission will be validated to ensure it is assigned to the organization.customerId
: String. Optional, when present, the permission will be validated to ensure it is assigned to the customer. Note: Cannot be used in combination with the organizationId
propregion
: String or boolean. Optional, default: true
. When a string, the permission will be validated to ensure it is assigned in the region. When true, the current region will be used.unauthorized
: Node. Optional. The content which will be render when the user does not have the permissions required.children
: Node. Required. The content which will be render when the user does have the permissions required.negate
: Boolean. Optional, default false
. negation the authorization (if the user does have the permissions specified, they will be "unauthorized" (shown the unauthorized
prop content) and if the do not have the permissions specified, they will be "authorized" and able to see the children content)import React from 'react';
import Authorize from '@availity/authorize';
// ...
<Authorize permissions={['1234', '2345', ['3456', '4567'], ['5678', '6789']]} organizationId="1495">
{/* ... */}
</Authorize>
// ...
Hook which validates the user's permissions and return if the user is authorized or not.
permissions
: String, number, or an array containing strings/numbers or an array containing strings/numbers. Required.
'1234'
['1234', '2345', ['3456', '4567'], ['5678', '6789']]
. The items in deep/nested array indicate permission IDs which must all be granted to the user to be consider authorized, they act as "and". The items in the top array act as 'or', if any are granted to the user the user would be consider authorized. The example ['1234', '2345', ['3456', '4567'], ['5678', '6789']]
would be similar '1234' || '2345' || ('3456' && '4567') || ('5678' && '6789')
options
object. optional. additional options
organizationId
: String. Optional, when present, the permission will be validated to ensure it is assigned to the organization.customerId
: String. Optional, when present, the permission will be validated to ensure it is assigned to the customer. Note: Cannot be used in combination with the organizationId
propregion
: String or boolean. Optional, default: true
. When a string, the permission will be validated to ensure it is assigned in the region. When true, the current region will be used.import React from 'react';
import { useAuthorize } from '@availity/authorize';
// ...
export default () => {
const [authorized,loading] = useAuthorized(["1234","5678"], {
region: 'FL'
})
return authorized && <SomeAuthorizedComponent />
}
// ...
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A survey of 500 cybersecurity pros reveals high pay isn't enough—lack of growth and flexibility is driving attrition and risking organizational security.
Product
Socket, the leader in open source security, is now available on Google Cloud Marketplace for simplified procurement and enhanced protection against supply chain attacks.
Security News
Corepack will be phased out from future Node.js releases following a TSC vote.