I need to have one of my RadzenDropdowns content change according to the Entra ID user logged in. Does anyone know of a good source that supply best practices for this?
You can filter the data based on the current user (available from the SecurityService which is injected in every page). How do you populate your dropdown?
I do the following
var result = await PPADbService.GetPlants(new Query { Top = args.Top, Skip = args.Skip, Filter = args.Filter, OrderBy = args.OrderBy });
Each user has access to a specfic set of plants
that they can enter data for.
I created a table that lists all the users and the plant(s) they have access to.
GetPlants
is implemented as such
var uri = new Uri(baseUri, $"Plants");
uri = Radzen.ODataExtensions.GetODataUri(uri: uri, filter:filter, top:top, skip:skip, orderby:orderby, expand:expand, select:select, count:count);
``
You can try the approach from here: Customize CRUD pages | Create a Blazor CRM application with Radzen Blazor Studio | Radzen Blazor Studio
To add a partial method to the OData controller which filters by the current user. Don't forget to add [Authorize]
attribute to the controller. The user should be accessible via the controller User
property.
It is supposed to work. Did you try it?
I have tried it. I like the way it works. This is done in the service, but do you think I could also do this in the controller?
You can check if the information available in the User
property of the controller meets your needs. Use the debugger for that. Also don't forget to add the [Authorize]
attribute to the controller as shown in that article.