Skip to content

Releases: w01fgang/react-permission-gate

1.0.6: :label: fix type def

23 Jul 14:20
196d863
Compare
Choose a tag to compare

Fix flow type definition

Fix flow type

23 Jul 14:13
c51c388
Compare
Choose a tag to compare
:label: fix flow type

Signed-off-by: w01fgang <[email protected]>

Fix missing validator in context

05 Jun 21:09
eb8a727
Compare
Choose a tag to compare
Merge pull request #2 from w01fgang/pass-validator-to-context

🐛 pass validator to context

Upgrade dependencies

02 Apr 19:26
c02ae58
Compare
Choose a tag to compare
:bookmark: bump version

Signed-off-by: w01fgang <[email protected]>

Expose validator function

11 Aug 10:43
668ab46
Compare
Choose a tag to compare

After this release, you can provide your own validator function.

import { PermissionGateProvider } from 'permission-gate';
...

// define or get from api rules and freeze them
const rules = Object.freeze({
  componentName: ['admin', 'user', 'other-role'],
  anotherComponentName: ['admin'],
});

function validator({ role, rulesMap, name }) {
  // default validator implementation
  const scope = rulesMap[name];
  if (!scope) return true;

  return scope.includes(role);
}

function MyApp() {
  const role = 'user'; // get from authenticated user

  return (
    <PermissionGateProvider role={role} rulesMap={rules} validator={validator}>
      <App />
    </PermissionGateProvider>
  )
}

Automate package publish

02 Jul 20:02
5796654
Compare
Choose a tag to compare

No code has changed. If you use 1.0.0, then you don't need this update.

First release

02 Jul 19:19
34cf721
Compare
Choose a tag to compare
1.0.0

:green_heart: add github action