Käyttäjän "marketbus" toiminnot

Vastaus

So are you saying don't use Angular for this? and just override what's in Themes/LeptonX/Layouts/Account in the MVC project?

Or are you saying that I would have to use the resource owner password flow if I want to do it in Angular?

That seemed to be the issue. Even though the appsettings.secret.json file was loaded, which I confirmed, the key was not being loaded. Copying the license key to appsettings.json works. The issue with isolated function apps is that many errors that are not in-code, are swallowed, and the above generic message is displayed. It's an issue that's been reported many times already. https://github.com/Azure/azure-functions-dotnet-worker/issues/532#issuecomment-1384065083

I might either create a gist or simple guide for this. I lost almost a week trying to get this to work :)

The example you gave is for in-process worker functions. But I did update the code as follows, I am still getting an error on some modules, but the below works and I am able to inject IIdentityUserRepository and query it.

[Program.cs]

using Autofac;
using Autofac.Extensions.DependencyInjection;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Identity;
using Volo.Abp.Threading;
using Sample.SecondProcessor;

var host = new HostBuilder()
    .UseServiceProviderFactory(new AutofacServiceProviderFactory())
    .AddAppSettingsSecretsJson()
    .UseAutofac()
    .ConfigureContainer<ContainerBuilder>(builder =>
    {
    })
    .ConfigureAppConfiguration((hostContext, config) =>
    {
        config.AddJsonFile("appsettings.json", optional: false);
    })
    .ConfigureServices(services =>
    {
        services.AddSingleton<ICancellationTokenProvider>(NullCancellationTokenProvider.Instance);
        services.AddSingleton<IAbpLazyServiceProvider,AbpLazyServiceProvider>();
        
        services.AddApplication<AzureFunctionProcessorModule>(x =>
        {
            x.UseAutofac();
        });        
        
        var serviceProvider = services.BuildServiceProvider();
        
        serviceProvider.GetRequiredService<IAbpApplicationWithExternalServiceProvider>().Initialize(serviceProvider);
    })
    .ConfigureFunctionsWorkerDefaults()
    .Build();

host.Run();


[SampleModule.cs]

using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Autofac;
using Volo.Abp.BackgroundJobs;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain;
using Volo.Abp.Identity;
using Volo.Abp.Identity.MongoDB;
using Volo.Abp.Modularity;
using Volo.Abp.OpenIddict.Tokens;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
using Sample.MongoDB;

namespace Sample.SecondProcessor;

[DependsOn(
    typeof(AbpIdentityDomainModule),
    typeof(AbpAutofacModule),
    typeof(AbpIdentityMongoDbModule),
    typeof(SampleApplicationContractsModule),
    //typeof(SampleMongoDbModule)
)]

public class AzureFunctionProcessorModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddTransient<IIdentityUserRepository, MongoIdentityUserRepository>();
        
        Configure<AbpUnitOfWorkDefaultOptions>(options =>
        {
            options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
        });
        
        Configure<AbpBackgroundJobOptions>(options =>
        {
            options.IsJobExecutionEnabled = false;
        });
        
        Configure<TokenCleanupOptions>(options =>
        {
            options.IsCleanupEnabled = false;
        });
    }
    
    public override void OnApplicationInitialization(ApplicationInitializationContext context)
    {
    }
}

If I uncomment SampleMongoDbModule, it fails and I get the generic :

[2023-05-02T17:58:14.180Z] Language Worker Process exited. Pid=30853. [2023-05-02T17:58:14.180Z] dotnet exited with code 214 (0xD6). . [2023-05-02T17:58:14.277Z] Failed to start a new language worker for runtime: dotnet-isolated. [2023-05-02T17:58:14.277Z] System.Private.CoreLib: A task was canceled.

Otherwise it works. Also, most of the Pro modules fail with the same error. I thought it might be a license key issue? So I added .AddAppSettingsSecretsJson() and copied my key over. However, it still fails. Also note, that I had to set both IsJobExecutionEnabled and IsCleanupEnabled to false or else it would throw an exception as in the screenshot in my previous comment.

I believe this will work in In-process mode, but I don't want to have to downgrade my projects to NET 6.0.

Do you mind being a bit more specific? Where exactly are you referring to?

For example, the below produces the same error.

using Volo.Abp;
using Volo.Abp.Autofac;
using Volo.Abp.Identity;
using Volo.Abp.Modularity;
using WholesaleFriendly.MongoDB;

namespace WholesaleFriendly.Processor;

[DependsOn(typeof(WholesaleFriendlyMongoDbModule))]
[DependsOn(typeof(AbpIdentityApplicationModule))]
[DependsOn(typeof(AbpAutofacModule))]
public class AzureFunctionProcessorModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
    }
    
    public override void OnApplicationInitialization(ApplicationInitializationContext context)
    {
    }
}

I updated the code based upon the links that you've send. I am getting the error as below. I am trying to lookup a user, in the Azure Activity Function I have the following:

public CreateTestFunction(IIdentityUserRepository identityUserRepository, IProductRepository productRepository)
{
    _identityUserRepository = identityUserRepository;
    _productRepository = productRepository;
}

Exception:

Volo.Abp. AbpInitializationException Create breakpoint: An error occurred during the initialize Volo. Abp. Modularity. OnApplicationInitializationModuleLifecycleContributor phase of the module sVolo.Abp. BackgroundJobs. AbpBackgroundJobsModule, Volo. Abp.BackgroundJobs, Version=7.0.1.0, 2 Culture=neutral, PublicKeyToken=null: Object reference not set to an instance of an object.. See, § the inner exception for details. ---> System. NullReferenceException Create breakpoint : Object reference not set to an instance of an object. at Volo. Abp. BackgroundWorkers. BackgroundWorkerBase. get_Logger at Volo.Abp. BackgroundWorkers. BackgroundWorkerBase. StartAsync(CancellationToken cancellationToken)

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Volo.Abp;
using Volo.Abp.Threading;
using Sample.Processor;
using Sample.Processor.Options;

var hostBuilder = new HostBuilder()
    .ConfigureFunctionsWorkerDefaults()
    .ConfigureAppConfiguration((hostContext, config) =>
    {
        config.AddJsonFile("appsettings.json", optional: false);
    })
    .ConfigureServices(async (hostBuilderContext, services) =>
    {
        services.AddOptions();

        await services.AddApplicationAsync<AzureFunctionProcessorModule>(x =>
        {
            x.Services.ReplaceConfiguration(hostBuilderContext.Configuration);
        });
        
        services.Configure<ProcessorOptions>(hostBuilderContext.Configuration.GetSection(nameof(ProcessorOptions)));

        services.AddLogging();
    });

var host = hostBuilder.Build();

var application = host.Services.GetRequiredService<IAbpApplicationWithExternalServiceProvider>();
var applicationLifetime = host.Services.GetRequiredService<IHostApplicationLifetime>();

applicationLifetime.ApplicationStopping.Register(() =>
{
    AsyncHelper.RunSync(() => application.ShutdownAsync());
});

applicationLifetime.ApplicationStopped.Register(() =>
{
    application.Dispose();
});

await application.InitializeAsync(host.Services);

host.Run();

using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
using Volo.Abp.Autofac;
using Volo.Abp.Identity;
using Volo.Abp.Identity.MongoDB;
using Volo.Abp.Modularity;
using Sample.MongoDB;

namespace Sample.Processor;

[DependsOn(typeof(WholesaleFriendlyMongoDbModule))]
[DependsOn(typeof(AbpIdentityApplicationModule))]
[DependsOn(typeof(AbpAutofacModule))]
public class AzureFunctionProcessorModule : AbpModule
{
    public override void PreConfigureServices(ServiceConfigurationContext context)
    {
    }

    public override void ConfigureServices(ServiceConfigurationContext context)
    {
        context.Services.AddTransient<IIdentityUserRepository, MongoIdentityUserRepository>();
    }
    
    public override void OnApplicationInitialization(ApplicationInitializationContext context)
    {
    }
}

Also, which nugets should I include in this project?

Thanks.

Let me clarify my last question. I would like to query on the extra property. So for example, if I wanted to query on where fullname = "Tom" or stripeId = "123".

Thanks...

There are several places in the UI that uses first name. So I am assuming that I would have to override all of those components with new ones as in https://docs.abp.io/en/abp/latest/UI/Blazor/Customization-Overriding-Components?UI=BlazorServer

ABP has excellent localization support. But I believe not using FullName might be a miss. The concept of surname and name changes quite a bit depending on local. Certain parts of Europe, Latin America, East Asia, etc don't use the standard name, surname format.

Also is there anyway to query ExtraProperties using the default repositories? I am assuming I would have to create a MyIdentityUserRepository that inherits from IdentityUserRepository and override the GetListAsync method or Add my own GetListWithExtraAsync and include stripeId and fullName, for example.

Which one of the three questions are answering with that link? Number 1?

Updating the UI is not really a problem, but those changes would have to flow through the system to the database. During registration, only the username, email address, and password will be sent back to the AccountApp service. I would need to include the First and Surname of the user. Would I have to extend the current AccountAppService and override the RegisterAsync method? [Edit] I just looked at the RegisterDto, it doesn't include First or Surname of the user.

For my 3rd question, for extending the UserIdentity, I can just use SetProperty on the IdentityUser, I believe since I am using MongoDb, it should make a difference in regards to searching by the stripeId as it should just add a property onto the document... correct?

That seemed to have did the trick.

My goal is to replace the login experience with Auth0. Meaning that instead of the ABP.IO login page, it will use Auth0's login modules, etc. Would it be sufficient to make the changes above, and update the Angular base template to use the Auth0 login package? I am curious how this will have an impact on things such as permissions, etc as all the roles and scopes will be maintained in Auth0.

Thanks.

Näytetään 1 - 10/24 tietueesta
Made with ❤️ on ABP v8.2.0-preview Updated on maaliskuuta 25, 2024, 15.11