Open atans96 opened 5 months ago
One of the design goals of Mashroom was to make the Apps portable and maximally reusable, therefore it is not possible to directly check some roles (which may be different from server to server). Instead, you can define permissions which are mapped to roles in the metadata. The App itself only receives a map of "permission name" -> boolean.
It works like this:
{
"mashroom": {
"plugins": [
{
// ...
"defaultConfig": {
// ...
"rolePermissions": {
"allowedTodoSomethingSpecial": ["Role2", "Role3"]
}
}
}
]
}
}
And in the App you can check if the user has the permission "allowedTodoSomethingSpecial" like this:
const bootstrap: MashroomPortalAppPluginBootstrapFunction = (portalAppHostElement, portalAppSetup, clientServices) => {
const {appConfig: {markdownMessage, pingButtonLabel}, user} = portalAppSetup;
if (user.permissions.allowedTodoSomethingSpecial) {
// ...
}
}
You could then change the mapping for every server instance in the "plugins" section of the server config.
I am developing a ReactJS plugin application (let's call it "plugin-app2") that will be integrated with the Mashroom portal web application. In this plugin application, I need to check the user's role to conditionally show or hide certain functionalities based on their permissions.
Is there a way to retrieve the roles assigned to the currently logged-in user within the Mashroom portal? This information would allow me to control the visibility of features in my ReactJS plugin application based on the user's role and permissions.
If there is a method or API provided by the Mashroom portal to access the user's role information, could someone please guide me on how to implement it in my ReactJS application?
Maybe this?
Any help or suggestions would be greatly appreciated.