hasPermission

hasPermission is a helper function to check for signed in users permissions.

This method is built along with Permissions to check for the configured permissions for mapped ids

pagePermissions

hasPermission is a function that takes in the ID for the permission you want to match against, then checks which roles are mapped to it and determines if the current user has this role, then returns a boolean value depending on the outcome.

How to use

import { Plugin } from '@root'

import CreateButton from '@components/CreateButton'
import UpdateButton from '@components/UpdateButton'

import {
    Wrapper
} from './style'

const MyApplication = () => {
    return (
        <Wrapper>
            {
                Plugin.hasPermission('PERMISSION_TO_CREATE_ID') && (
                    <CreateButton/>
                )
            }
            
            {
                Plugin.hasPermission('PERMISSION_TO_UPDATE_ID') && (
                    <UpdateButton/>
                )
            }
        </Wrapper>
    )
}

export {
    MyApplication
}

PERMISSION_TO_CREATE_ID and PERMISSION_TO_UPDATE_ID are ids that has been registered with permissionKeys with Plugin.register() method

Last updated