1.1.0 • Published 3 years ago

r2-access-permission v1.1.0

Weekly downloads
18
License
ISC
Repository
github
Last release
3 years ago

React Router Access Permission

This library makes React components available for display or redirect if user does not have access.

Permission Redirect

If you need redirect the user to another uri, if he not have access, you could use <PermissionRedirect />.

Redirect Props

PropertyTypeDescription
authoritiesArray of StringList of authorities to verify.
authorityStringAuthority that user need to access the child component.
redirectStringURI to send user if he not have permission to access.
childrenStringA child component to render.

Example:

const authorities = [
  'ROLE_FOO'
],

const Compoment = () => {
  return (
    <PermissionRedirect authorities={authorities} authority={'ROLE_BAR'} redirect="/logout">
      <div>You have access!</div>
    </PermissionRedirect>
  );
}

Permission Render

If you need hide some component you could use <PermissionRender />.

Render Props

PropertyTypeDescription
authoritiesArray of StringList of authorities to verify.
authorityStringAuthority that user need to access the child component.
compomentReact ComponentComponent rendered if user if he not have permission to access.
childrenReact ComponentA child component to render.

Example:

const authorities = [
  'ROLE_FOO'
],

const Compoment = () => {
  return (
    <PermissionRender authorities={authorities} authority={'ROLE_BAR'} component={<div>You haven't access!</div>}>
      <div>You have access!</div>
    </PermissionRender>
  );
}

Enjoy the library and Thank you for use it

Reginaldo Morais

1.1.0

3 years ago

1.0.1

3 years ago

1.0.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago