-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accessing current user roles #424
Comments
We're developing and maintaining a suite of plugins for our in-house "site builder" platform, which is powered by Storyblok. As our plugins grow in complexity, we've identified a need to leverage the roles and permissions systems. This would allow us to dynamically show or hide elements within our plugins based on specific user access levels. Consider a scenario where we have a plugin that displays various options depending on the user's role. To implement this functionality effectively, we need a way to access information about the user's assigned role or individual permissions within Storyblok. For instance, if a user has publishing rights for stories, we might want to present them with an expanded set of options within our plugin. |
This would be great |
created the support ticket: https://support.storyblok.com/hc/en-us/requests/13886 this is becoming extra critical for us @BibiSebi |
Resend your request internally, so we can consider this for development sooner. cc @demetriusfeijoo |
In the latest package release, the cc @marckraw. Should we keep it open for the roles, or can you make the proper request with the user ID to grab that information? |
@Dawntraoz amaaaaaazing! will test it right away today 🥇 |
@Dawntraoz would be great if we can get the roles already, but we can start working with |
@Dawntraoz tested it out, and its there, thank you <3 If its possible, we would like to also have a user roles in there - right now, having the |
Thanks for checking you are the best! 🎉 Good news from our side also @marckraw, in the plugin we are building now we will need to get the roles too, so we will take the time to make it available for the SDK 🙏 It's coming 💃🏻 |
@Dawntraoz that is amazing! Looking forward to it :) Was working on getting the roles for the user with management api, but it involved more back and forth than I expected :P
Here is more or less what I do in the plugin to get all this info:
At least that was my flow, but for sure i'm missing something :D Anyway, would be nice to know, what is your idea of what will you exposed, so we can prepare ourselves accordingly :) |
Hi @marckraw 👋 We are currently finishing a solution that may cover your company's needs, we decided to create an action called "requestUserContext" that will return a Initially, it won't be returned; you need to call it and await the result to get it, so it's not in the load process of the plugin but an additional feature, so it doesn't affect the plugin performance 🙏 Will this cover all your needs? |
Hey @Dawntraoz super nice to hear it! It’s great to hear from you—thanks for taking care of it! 😊 I have a 2 more questions:
Here’s why I ask: In our plugin, we have subfields we’d like to show or hide depending on the role. If we can retrieve the role name, we can implement this logic directly in our plugin. But if the roles themselves could store these custom strings and return them, it would simplify things even more. For context, we mostly create roles through the Management API (using sb-mig) during space setup. Here’s an example of our configuration for the only-content-editor custom role:
If we could extend the permissions array with custom strings, like so:
…it would make things perfect for our use case! Let me know if this is feasible :P Thanks a lot for your help! :) |
@Dawntraoz I just checked that it doest not validate hard on backend and i can send some arbitrary strings to |
Hi @marckraw 👋 Let me answer your questions:
What is the use case here if the permissions are already based on the user roles 🤔 Aren't they sufficient?
That's more of a product API question; I'm afraid the Field Plugin doesn't have control over it. We are just representing here what the product API is returning, so if you can add them and get them with the MAPI, then the plugin will showcase the same ones you got. PS: If you want to be sure if this will be validated harder in the future, I recommend you to open a question query in Support, so they can answer you with the right information 🙏 |
The issue we’re facing is that our plugin introduces its own concept of “subfields,” which aren’t recognized by Storyblok’s permission system. Because of this, we can’t leverage Storyblok’s GUI to manage which of these subfields should be shown or hidden for specific roles.
To provide some context, here’s a snapshot of what our situation looks like. This Design field is a custom field plugin, and inside it, we have additional subfields: Not sure if I've explained it enough :D I can also record some screencast or we can hop on a call and I can show you in details. So yeah, returning the name of the role will give us some way to add some more permissions if we need to. Still we can get the role name using management api workaround, but if you would add it to the response we would have 100% use cases covered. Anyway, thank you for investigating it even further :)
Got it 👍🏻
Will do that too then :) |
Is your feature request related to a problem? Please describe.
The developer of a plugin would like to show/hide parts of the plugin based on the current user's roles. This is not possible at the moment as we are not passing the user information to the field plugin.
Describe the solution you'd like
useFieldPlugin()
could expose the current user's roles and id. However we need to check if this can be exploited in any way.Additional context
This request originates from a Discord thread.
The text was updated successfully, but these errors were encountered: