Hi, you need to create a custom event handler for that purpose. Please apply the following steps:
using System.Threading.Tasks;
using OpenIddict.Server;
namespace MySolution;
public class SignOutEventHandler : IOpenIddictServerHandler<OpenIddictServerEvents.ProcessSignOutContext>
{
public static OpenIddictServerHandlerDescriptor Descriptor { get; }
= OpenIddictServerHandlerDescriptor.CreateBuilder<OpenIddictServerEvents.ProcessSignOutContext>()
.UseSingletonHandler<SignOutEventHandler>()
.SetOrder(100_000)
.SetType(OpenIddictServerHandlerType.Custom)
.Build();
public ValueTask HandleAsync(OpenIddictServerEvents.ProcessSignOutContext context)
{
//your logic...
return ValueTask.CompletedTask;
}
}
public class MySolutionHttpApiHostModule : AbpModule
{
public override void PreConfigureServices(ServiceConfigurationContext context)
{
//...
PreConfigure<OpenIddictServerBuilder>(serverBuilder =>
{
serverBuilder.AddEventHandler(SignOutEventHandler.Descriptor);
});
//...
}
}
SignOutEventHandler class's HandleAsync method trigger after every signout request.Hi again, I have checked your project and found the problem. Everything you did was correct and necessary, however, it seems you missed setting the related localization files as EmbeddedResource. This is required for the production environment.
You should add the following lines to the *.Domain.Shared.csproj file, and then it should work as expected:
<ItemGroup>
<EmbeddedResource Include="Localization\ManasotaErp\*.json" />
<Content Remove="Localization\ManasotaErp\*.json" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Localization\AbpIdentity\*.json" />
<Content Remove="Localization\AbpAccount\*.json" />
</ItemGroup>
Best regards.
Update: I got your project and checking currently. I will write you back asap.
Thanks, the issue is resolved. So, for each module, if I want to use FullAuditedEntityWithUser or establish a relationship with IdentityUser, I need to follow the same steps, correct?
Yes, that's right 👍Because, you need to have the relationship for the IdentityUser entity.
I'm closing the question since your problem is resolved. Best regards.
Hi, I will create an internal issue for your feature request. Thanks for your suggestion.
Regards.
Hi, I checked your project and found the problem. In your shared.entityframeworkcore project, you should call the builder.ConfigureIdentityPro() before your entity configuration. Because you are using the FullAuditedEntityWithUser in the UserNotification entity.
Here is what you should do:
<PackageReference Include="Volo.Abp.Identity.Pro.EntityFrameworkCore" Version="9.0.4" /> to Shared.EntityFrameworkCore.csproj.typeof(AbpIdentityProEntityFrameworkCoreModule) this depends on statement to SharedEntityFrameworkCoreModule class.SharedDbContext class, and update it as follows (don't forget to add builder.ConfigureIdentityPro()):using Microsoft.EntityFrameworkCore;
using Shared.EntityFrameworkCore.Configurations;
using Shared.Notifications;
using Shared.NotificationTemplates;
using Shared.UserDevices;
using Shared.UserNotifications;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity;
using Volo.Abp.Identity.EntityFrameworkCore;
namespace Shared.EntityFrameworkCore;
[ReplaceDbContext(typeof(IIdentityProDbContext))]
[ConnectionStringName(SharedDbProperties.ConnectionStringName)]
public class SharedDbContext : AbpDbContext<SharedDbContext>, ISharedDbContext, IIdentityProDbContext
{
/* Add DbSet for each Aggregate Root here. Example:
* public DbSet<Question> Questions { get; set; }
*/
public DbSet<UserNotification> UserNotifications { get; set; }
public DbSet<Notification> Notifications { get; set; }
public DbSet<NotificationTemplate> NotificationTemplates { get; set; }
public DbSet<UserDevice> UserDevices { get; set; }
public SharedDbContext(DbContextOptions<SharedDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.ConfigureIdentityPro();
builder.ConfigureShared();
}
//Identity
public DbSet<IdentityUser> Users { get; }
public DbSet<IdentityRole> Roles { get; }
public DbSet<IdentityClaimType> ClaimTypes { get; }
public DbSet<OrganizationUnit> OrganizationUnits { get; }
public DbSet<IdentitySecurityLog> SecurityLogs { get; }
public DbSet<IdentityLinkUser> LinkUsers { get; }
public DbSet<IdentityUserDelegation> UserDelegations { get; }
public DbSet<IdentitySession> Sessions { get; }
}
Then, run the dbmigrator without having a problem.
Hi, I got your project now and trying to reproduce the problem. I will write back to you asap.
Regards.
Hi, can you please check this answer and see if it answers your question?
or User Organization Unit and its dependent Organization Unit in the hierarchy,
Hi, you can use the IdentityUserAppService's GetOrganizationUnitsAsync(Guid id) to get a user's all organization units. The result will be List<OrganizationUnitDto> and you can see the parentId's of the related organization units. If it's null, then it means it's a root organization unit.
Regards.
Hi @EngincanV,
Sure. Here are two documentation that you can refer:
I think these docs are not related as the issue is not related to cascade/restrict delete. I want to delete the dependent entity, instead of the principal entity.
Did you test my working ASP.NET Core Web API example app? https://cdn.fuzed.app/share/abp/EFCorePlayground.zip
The following ABP framework example app, with the same EF Core configuration, doesn't work: https://cdn.fuzed.app/share/abp/AbpEFCorePlayground.zip
Best regards, Steff Beckers
Hi, sorry for the misunderstanding (I thought you were expecting a cascade delete/update behavior). I will check your project and write you back asap.