Releases: w01fgang/react-permission-gate
Releases · w01fgang/react-permission-gate
1.0.6: :label: fix type def
Fix flow type
:label: fix flow type Signed-off-by: w01fgang <[email protected]>
Fix missing validator in context
Merge pull request #2 from w01fgang/pass-validator-to-context 🐛 pass validator to context
Upgrade dependencies
:bookmark: bump version Signed-off-by: w01fgang <[email protected]>
Expose validator function
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
No code has changed. If you use 1.0.0, then you don't need this update.
First release
1.0.0 :green_heart: add github action