Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] UserManager.SetOrganizationUnitsAsync With UnitOfWork #4660

Closed
aricyu opened this issue Jul 1, 2019 · 1 comment · Fixed by #4662
Closed

[Bug] UserManager.SetOrganizationUnitsAsync With UnitOfWork #4660

aricyu opened this issue Jul 1, 2019 · 1 comment · Fixed by #4662
Assignees
Labels
Milestone

Comments

@aricyu
Copy link
Contributor

aricyu commented Jul 1, 2019

  • Abp package version:4.60..
  • base framework: .Net Core.
  • Exception message and stack trace if available.
ERROR 2019-07-01 19:22:48,062 [56   ] Mvc.ExceptionHandling.AbpExceptionFilter - Can not set more than 1 organization unit for a user!
Abp.AbpException: Can not set more than 1 organization unit for a user!
   at Abp.Authorization.Users.AbpUserManager`2.CheckMaxUserOrganizationUnitMembershipCountAsync(Nullable`1 tenantId, Int32 requestedCount) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore\Authorization\Users\AbpUserManager.cs:line 513
   at Abp.Authorization.Users.AbpUserManager`2.AddToOrganizationUnitAsync(TUser user, OrganizationUnit ou) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore\Authorization\Users\AbpUserManager.cs:line 487
   at Abp.Authorization.Users.AbpUserManager`2.SetOrganizationUnitsAsync(TUser user, Int64[] organizationUnitIds) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore\Authorization\Users\AbpUserManager.cs:line 545
   at Abp.Authorization.Users.AbpUserManager`2.SetOrganizationUnitsAsync(Int64 userId, Int64[] organizationUnitIds) in D:\Github\aspnetboilerplate\src\Abp.ZeroCore\Authorization\Users\AbpUserManager.cs:line 505
   at CsprojBuilder.Authorization.Users.UserAppService.UpdateUserInAdminAsync(UserInputDto input) in D:\Work\Projects\aspnet-core\src\CsprojBuilder.Application\Authorization\Users\UserAppService.cs:line 275
   at CsprojBuilder.Authorization.Users.UserAppService.CreateOrUpdateUserAsync(UserInputDto input) in D:\Work\Projects\aspnet-core\src\CsprojBuilder.Application\Authorization\Users\UserAppService.cs:line 204
   at lambda_method(Closure , Object )
   at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.AwaitableResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
   at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextExceptionFilterAsync()
  • Steps needed to reproduce the problem.
    in GetSettingDefinitions
context.Manager.GetSettingDefinition(AbpZeroSettingNames.OrganizationUnits.MaxUserMembershipCount).DefaultValue = "1";

SetOrganizationUnitsAsync is the first to remove the collection (RemoveFromOrganizationUnitAsync) and then add the new one (AddToOrganizationUnitAsync).
However, due to UnitOfWork, RemoveFromOrganizationUnitAsync does not take effect.

await CheckMaxUserOrganizationUnitMembershipCountAsync(user.TenantId, currentOus.Count + 1);

@ismcagdas ismcagdas added the bug label Jul 1, 2019
@ismcagdas ismcagdas added this to the v4.7 milestone Jul 1, 2019
@ismcagdas
Copy link
Member

Thanks @ChiakiYu we will fix this.

demirmusa pushed a commit that referenced this issue Jul 1, 2019
ismcagdas added a commit that referenced this issue Jul 1, 2019
ziranquliu pushed a commit to ziranquliu/aspnetboilerplate that referenced this issue Jul 2, 2019
…erplate into dev

* 'dev' of https://github.com/aspnetboilerplate/aspnetboilerplate: (49 commits)
  resolves aspnetboilerplate#4660
  aspnetboilerplate#4657: Update System.Runtime tp 4.3.1 for netcoreapp2.2 TargetFramework
  updated abp.min.js
  redis cache unity test error fix
  nuget packages updated
  resolves  aspnetboilerplate#4462
  Update README.md
  resolved aspnetboilerplate#4504: make GetEntityId of EntityHistoryHelper protected virtual
  fixed aspnetboilerplate#4453: use AbpMvcContractResolver instead of DateFormatString for dmeo project
  formatted some code blocks
  allow changing period of UserTokenExpirationWorker
  non-trailing named arguments error
  notification store, startDate endDate added to get and delete methods aspnetboilerplate#4639
  Upgraded to Hangfire 1.7.3
  resolve aspnetboilerplate#4560 Improve the constructor of UnitOfWork.
  DbQuery supports the use of Repository.
  DbQuery unit test.
  fix aspnetboilerplate#4556 Exclude soft deleted roles when removing user roles.
  change TenantCache.HandleEvent to virtual method
  Move the Castle.Facilities.AspNet.SystemWeb package to the Abp.Web project.
  ...
ziranquliu pushed a commit to ziranquliu/aspnetboilerplate that referenced this issue Jul 3, 2019
…oilerplate

* 'master' of https://github.com/aspnetboilerplate/aspnetboilerplate: (47 commits)
  redis cache serialize test cases multiple dll error fix
  completes aspnetboilerplate#4662: make SetOrganizationUnitsAsync methods unitOfWork
  The AbpFeatureValueStore should handle the EntityChangingEvent to invalidate the cache in time.
  resolves aspnetboilerplate#4660
  aspnetboilerplate#4657: Update System.Runtime tp 4.3.1 for netcoreapp2.2 TargetFramework
  updated abp.min.js
  redis cache unity test error fix
  nuget packages updated
  resolves  aspnetboilerplate#4462
  Update README.md
  resolved aspnetboilerplate#4504: make GetEntityId of EntityHistoryHelper protected virtual
  fixed aspnetboilerplate#4453: use AbpMvcContractResolver instead of DateFormatString for dmeo project
  formatted some code blocks
  allow changing period of UserTokenExpirationWorker
  non-trailing named arguments error
  notification store, startDate endDate added to get and delete methods aspnetboilerplate#4639
  Upgraded to Hangfire 1.7.3
  resolve aspnetboilerplate#4560 Improve the constructor of UnitOfWork.
  DbQuery supports the use of Repository.
  DbQuery unit test.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants