More flexibility needed to manage users

Hi Radzen,

I need to enable some of my users to create a user record from a Person record without giving them access to all users. Unfortunately, I am not able to do this because the createUser data source method only works if the user has access to the Application Users screen. This tethering of “functionality” to “visibility” is quite unfortunate…

I would also need to be able to add a role to a user programmatically, but there seems to be no built-in data source method to do that…

How could I achieve what I am trying to do with Radzen?

Thanks!

Hi Thierry,

You can use the custom method invoke approach to invoke custom server-side code for user create/update. Instead http.get you can use post, for example:

      ...
      this.http.post(`${url}api/custommethod/yourmethod`,
      {
        ... some json
      }).subscribe(data => {
         //
      });
    [Route("api/[controller]/[action]")]
    public class CustomMethodController : Controller
    {
        private UserManager<ApplicationUser> userManager;

        public CustomMethodController(UserManager<ApplicationUser> userManager)
        {
            this.userManager = userManager;
        }

        public IActionResult YourMethod([FromBody]JObject data)
        {
         ....

or you can override the security for the ApplicationUsersController using partial class:

    [Authorize(AuthenticationSchemes="Bearer", Roles = "yourrole")]
    public partial class ApplicationUsersController 
    {
       
    }

or

    [AllowAnonymous]
    public partial class ApplicationUsersController 
    {
       
    }

Best Regards,
Vladimir

Thank you, I will try it.