0
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)
{
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.
Have an answer to this question?
Log in
and write your answer.