abp icon indicating copy to clipboard operation
abp copied to clipboard

How to properly use IdentityUserManager in a custom module solution

Open buaziz opened this issue 5 years ago • 6 comments

ABP Framework version : v4.2.2 database provider : EF Core

I am trying to use IdentityUserManager inside a custom app service in a module solution.

what is the proper steps to include functionality from the ABP framework modules inside custom module solutions.?

buaziz avatar Mar 15 '21 18:03 buaziz

I can't get your point. you should check the ABP document. https://docs.abp.io/

realLiangshiwei avatar Mar 16 '21 00:03 realLiangshiwei

@realLiangshiwei When I try to use IdentityUserManager inside a custom app service in a module solution

I get this error : Cannot resolve parameter 'Volo.Abp.Identity.IdentityUserManager userManager'

When I add nuget package Volo.Abp.Identity.Application to Application Project of the module solution, and add [DependsOn(typeof(AbpIdentityApplicationModule))] , I get this error

System.NotSupportedException: Store does not implement IQueryableUserStore<TUser>.
   at Microsoft.AspNetCore.Identity.UserManager`1.get_Users()
   at Castle.Proxies.IdentityUserManagerProxy.get_Users_callback()
   at Castle.Proxies.Invocations.UserManager`1_get_Users.InvokeMethodOnTarget()
   at Castle.DynamicProxy.AbstractInvocation.Proceed()
   at Castle.DynamicProxy.AbstractInvocation.ProceedInfo.Invoke()
   at Castle.DynamicProxy.AsyncInterceptorBase.ProceedSynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)

I want to know the correct steps to include and use the framework modules inside my custom module solution

buaziz avatar Mar 16 '21 06:03 buaziz

System.NotSupportedException: Store does not implement IQueryableUserStore.

This interface is synchronous, and we do not recommend that you use userManager.Users etc. See https://github.com/abpframework/abp/issues/7402

maliming avatar Mar 16 '21 06:03 maliming

@maliming I am try to add a user lookup inside my custom module solution as below.

what are the steps from adding nuget/depends on or other steps, as all other issues are only showing the code.

  var query = UserManager.Users.AsQueryable()
                .WhereIf(!string.IsNullOrWhiteSpace(input.Filter),
                    x => x.Name != null &&
                         x.Name.Contains(input.Filter));

buaziz avatar Mar 16 '21 06:03 buaziz

You can use IIdentityUserRepository.

maliming avatar Mar 16 '21 06:03 maliming

Works after I added below nuget / depends on in the HOST API project

<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="4.2.2" /> [DependsOn(typeof(AbpIdentityEntityFrameworkCoreModule))]

buaziz avatar Mar 16 '21 07:03 buaziz