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)
{
CurrentUnitOfWork.DisableFilter(AbpDataFilters.MayHaveTenant);
User user = await UserManager.GetUserByIdAsync(input.id);
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
Hi,
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
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
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
No problem, have a nice day :)