Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Latest commit

 

History

History
executable file
·
38 lines (28 loc) · 1.34 KB

auth.md

File metadata and controls

executable file
·
38 lines (28 loc) · 1.34 KB

This project uses a fine-grained based CBAC permission control scheme.

how to use

Taking the ContributorList component as an example, assuming that this is not a public component, we use the withGuardian high-level component to wrap the ContributorList Export:

Const ContributorList = ({ users, readOnly, addContributor }) => (
  <Wrapper>
    ...
  </Wrapper>
)

ContributorList.propTypes = {
 ...
}

ContributorList.defaultProps = {
 ...
}

Export default withGuardian(ContributorList)

WithGuardian receives some permission-related parameters, the most important of which is the passport. Other containers or components can pass permission information when calling ContributorList:

<ContributorList
  Passport="root"
  fallbackProps="readOnly"
  Users={contributors}
  addContributor={addContributor}
/>

This component is not displayed if the permissions are not met. The fallbackProps parameter is optional, meaning that the component is used to display the component if the permission is not met.

Permission-related content is worthy of a detailed discussion, I will take the time to complete the document.