directus-extension-current-role-hook
v0.2.3
Published
This hook injects the current user role in the DOM
Downloads
3
Maintainers
Readme
Current Role
This hook injects the current user ID and role in the body element of the Data Studio. This is useful when you want to apply custom CSS to a specific user or role.
Usage
- Install the extension using a package manager or from the Marketplace:
npm install directus-extension-current-role-hook
Restart Directus.
Data attribute gets injected in the body element.
- Add your custom CSS:
body[data-user-id="..."] {
/* custom css */
}
body[data-user-role="..."] {
/* custom css */
}
Known Issues
- After installing the extension, you'll have to restart Directus for the extension to work.
- HTML attributes aren't injected after logging in because, upon initial load, the request to retrieve the user would be unauthenticated.