0
dmeagor created
ABP Framework version: 5.1.1 User Interface: Angular database provider: EF Core
When using the IdentityUserController and MaxUserCount has been set, the tenant is at the maximum number of users. Updating the details of an existing user is not possible.
If there a way to bypass this quickly?
Thanks in advance :)
[INF] Route matched with {area = "identity", controller = "User", action = "Update", page = ""}. Executing controller action with signature System.Threading.Tasks.Task1[Volo.Abp.Identity.IdentityUserDto] UpdateAsync(System.Guid, Volo.Abp.Identity.IdentityUserUpdateDto) on controller Volo.Abp.Identity.IdentityUserController (Volo.Abp.Identity.Pro.HttpApi).
[WRN] ---------- RemoteServiceErrorInfo ----------
Reached maximum allowed user count! This tenant is allowed to have a maximum of 3 users.
[WRN] Exception of type 'Volo.Abp.BusinessException' was thrown.
Volo.Abp.BusinessException: Exception of type 'Volo.Abp.BusinessException' was thrown
. at Volo.Abp.Identity.MaxUserCountValidator.CheckMaxUserCountAsync()
at Volo.Abp.Identity.MaxUserCountValidator.ValidateAsync(UserManager1 manager, IdentityUser user)
at Microsoft.AspNetCore.Identity.UserManager1.ValidateUserAsync(TUser user)
at Microsoft.AspNetCore.Identity.UserManager1.UpdateUserAsync(TUser user)
7 Answer(s)
-
0
hi
How many users do you have now? Is it three?
-
0
Hi
Yes, it's three users in the tenant when the error is thrown
-
0
ok, I will try to fix it.
-
0
Reopening as the bot appears to have closed this issue before resolution.
-
0
HI
This problem has been fixed.
PreConfigure<IdentityBuilder>(builder => { builder.Services.RemoveAll(x => x.ImplementationType == typeof(MaxUserCountValidator)); builder.AddUserValidator<MyMaxUserCountValidator>(); }); using System.Threading.Tasks; using Microsoft.AspNetCore.Identity; using Volo.Abp.Features; using Volo.Abp.Identity.Features; namespace Volo.Abp.Identity; public class MyMaxUserCountValidator : IUserValidator<IdentityUser> { protected IFeatureChecker FeatureChecker { get; } protected IIdentityUserRepository UserRepository { get; } public MyMaxUserCountValidator (IFeatureChecker featureChecker, IIdentityUserRepository userRepository) { FeatureChecker = featureChecker; UserRepository = userRepository; } public async Task<IdentityResult> ValidateAsync(UserManager<IdentityUser> manager, IdentityUser user) { await CheckMaxUserCountAsync(user); return IdentityResult.Success; } protected virtual async Task CheckMaxUserCountAsync(IdentityUser user) { var maxUserCount = await FeatureChecker.GetAsync<int>(IdentityProFeature.MaxUserCount); if (maxUserCount <= 0) { return; } var existUser = await UserRepository.FindAsync(user.Id); if (existUser == null) { var currentUserCount = await UserRepository.GetCountAsync(); if (currentUserCount >= maxUserCount) { throw new BusinessException(IdentityProErrorCodes.MaximumUserCount) .WithData("MaxUserCount", maxUserCount); } } } }
-
0
Thanks for that :)
Has it made it to the nuget packages yet?
-
0
Yes, 5.2-RC2