Open Closed

override createAsync in IdentityUserAppService not executed #4641


User avatar
0
peyman@debtrak.com created

ABP Framework version: v5.3.4

UI type: Angular

DB provider: EF Core

Tiered (MVC) or Identity Server Separated (Angular): yes Im trying custom create user by admin in abp,so override createAsync in IdentityUserAppService,but this part of code not executed

[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IIdentityUserAppService))]
public class CustomIdentityUserAppService : IdentityUserAppService
{

    #region DI

    private readonly IContactDapperRepository _contactDapperRepository;

    public CustomIdentityUserAppService(IdentityUserManager userManager, IIdentityUserRepository userRepository, IIdentityRoleRepository roleRepository,                 IOrganizationUnitRepository organizationUnitRepository, IIdentityClaimTypeRepository identityClaimTypeRepository, IdentityProTwoFactorManager                     identityProTwoFactorManager, IOptions<IdentityOptions> identityOptions, IDistributedEventBus distributedEventBus, IOptions<AbpIdentityOptions>                 abpIdentityOptions, IContactDapperRepository contactDapperRepository) : base(userManager, userRepository, roleRepository,                                       organizationUnitRepository,identityClaimTypeRepository, identityProTwoFactorManager, identityOptions, distributedEventBus, abpIdentityOptions)
    {
        _contactDapperRepository = contactDapperRepository;
    }

    #endregion

    public override async Task<IdentityUserDto> CreateAsync(IdentityUserCreateDto input)
    {

        var x = await base.CreateAsync(input);
        var userContactId = CurrentUser.GetContactId().ToInt().GetValueOrDefault();
        var userSessionId = CurrentUser.GetUserSessionId().ToInt();
        var contactId = await _contactDapperRepository.CreateUserAsync(input, null, userContactId, userSessionId);

        return x;
    }

i try this

[ExposeServices( typeof(IIdentityUserAppService), typeof(IdentityUserAppService), typeof(CustomIdentityUserAppService))]

and this too [ExposeServices(typeof(CustomIdentityUserAppService), typeof(IIdentityUserAppService), typeof(IdentityUserAppService))]

but not working yet


9 Answer(s)
  • User Avatar
    0
    salih created
    Support Team .NET Developer

    Can you try this way? [Dependency(ServiceLifetime.Transient, ReplaceServices = true)]

  • User Avatar
    0
    peyman@debtrak.com created

    Can you try this way? [Dependency(ServiceLifetime.Transient, ReplaceServices = true)]

    I try this but override createAsync in IdentityUserAppService not executed

  • User Avatar
    0
    salih created
    Support Team .NET Developer

    The return type is wrong in the code you tried. It worked when I fixed it

  • User Avatar
    0
    peyman@debtrak.com created

    The return type is wrong in the code you tried. It worked when I fixed it

    I fixed the return type but result not changed, your version is : v5.3.4? because as i see your constructor inputs are not same as i. for example you dont have distributedEventBus as input for constructor

  • User Avatar
    0
    salih created
    Support Team .NET Developer

    I fixed the return type but result not changed, your version is : v5.3.4? because as i see your constructor inputs are not same as i. for example you dont have distributedEventBus as input for constructor

    I tested it with MVC as it is a backend. That's why it's missing. Now I've created it with Angular. The command I use to create the project is: abp new Qa4641 --version 5.3.4 -u angular

  • User Avatar
    0
    peyman@debtrak.com created

    I fixed the return type but result not changed,
    your version is : v5.3.4? because as i see your constructor inputs are not same as i.
    for example you dont have distributedEventBus as input for constructor

    I tested it with MVC as it is a backend. That's why it's missing. Now I've created it with Angular. https://github.com/salihozkara/Qa4641/commit/17ea6c5e26a85f59580647cd444403794f93313b https://github.com/salihozkara/Qa4641/blob/master/aspnet-core/src/Qa4641.Domain.Shared/Qa4641.Domain.Shared.csproj#L19 The command I use to create the project is: abp new Qa4641 --version 5.3.4 -u angular

    I write the same code as you but my override method not executed.do u have any idea why this happen?

  • User Avatar
    0
    salih created
    Support Team .NET Developer

    Hello, are you trying to add a user from the admin page or to register? This code is working to add user from admin page. Can you create and share a project that doesn't work using this method? You can create a private repository on Github and authorize me.(https://github.com/salihozkara)

  • User Avatar
    0
    peyman@debtrak.com created

    Hello, are you trying to add a user from the admin page or to register? This code is working to add user from admin page. Can you create and share a project that doesn't work using this method? You can create a private repository on Github and authorize me.(https://github.com/salihozkara)

    I solved the problem . I moved class from identityServer project to the HttpApi.Host Project and problem Solved.

  • User Avatar
    0
    salih created
    Support Team .NET Developer

    I'm closing the question.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09