Base solution for your next web application
Spring Sale!
Time Offer!
XXdays : XXhrs : XXmin : XXsec
Open Closed

Updating user permissions issue #632

aranhico created

Hello, first of all, thank you so much for your great work on abp. I'm having some trouble while updating permissions on users, this is my code:

public async Task UpdateUserPermissions(UpdateUserPermissionsInput input)

            User user = await UserManager.GetUserByIdAsync(;
            await UserManager.ResetAllPermissionsAsync(user); // this line doesn't reset the permissions but if i used it "sepparatedlly" it works

            List<Permission> list = PermissionManager.GetAllPermissions().ToList();
            list = list.Where(x => input.Permissions.Contains(x.Name)).ToList();
            await UserManager.SetGrantedPermissionsAsync(user, list);

maybe my problem has something to do with the async/await, i believe I don't plenty understand it, maybe some of you can point me good litterature on the subject?

again, thank you !

4 Answer(s)
  • 0
    hikalkan created
    Support Team


    Why did you disabled AbpDataFilters.MayHaveTenant? I suppose no need for it.

    Also, you should not need to use ResetAllPermissionsAsync since SetGrantedPermissionsAsync removes other permissions automatically.

    Also, ResetAllPermissionsAsync does not clear permissions, just clears user specific permissions.

    Have a nice day.

  • 0
    aranhico created

    I disabled AbpDataFilters.MayHaveTenant because I'm trying to centralize things in just one tenant.

    SetGrantedPermissionsAsync its not prohibiting other permissions, i dont know why! That's why I tried to use ResetAllPermissionsAsync, to reset all user permissions

  • 0
    aranhico created

    I'm really sorry, the problem was getting the permissions for the user because i wasn't filtering by isgranted = true. thank very much for your help, and thank you for the excellent work

  • 0
    hikalkan created
    Support Team

    No problem, have a nice day :)