فتح مغلق

Add a user column to the token claims #3029


User avatar
0
Frontis خلقت
  • ABP Framework version: v5.1.4
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): no

Dear,

For one of our customers, we want to include an extra identification column, to the (bearer) token claims. It has to be an user column.

For this, i've added the column wisch works so far

**DtoExtensions.cs ObjectExtensionManager.Instance.AddOrUpdateProperty<IdentityUserDto, long>("MonteursId");

**ModuleExtensionConfigurator.cs

private static void ConfigureExtraProperties()
    {
        ObjectExtensionManager.Instance.Modules()
            .ConfigureIdentity(identity =>
            {
                identity.ConfigureUser(user =>
                {
                    user.AddOrUpdateProperty<long>("MonteursId");
                });
            });
    }

**EfCoreEntityExtensionMappings.cs

OneTimeRunner.Run(() =>
        {

            ObjectExtensionManager.Instance.MapEfCoreProperty<IdentityUser, long>(
                "MonteursId",
                (entityBuilder, propertyBuilder) =>
                { });
        });

We want the value of "monteursid" to appear in the token, just like it does when you add a claim by the dropdown as shown below.

I've tried multiple things, but it doesn't appear in the token. What can i do to make it happen?


1 إجابة (إجابات)
  • User Avatar
    0
    liangshiwei خلقت
    فريق الدعم Fullstack Developer

    Hi,

    There are two things, you mixed them up

    You can check this: https://support.abp.io/QA/Questions/2684/IAbpClaimsPrincipalContributor-doesn%27t-work-in-microservice-project

Made with ❤️ on ABP v8.2.0-preview Updated on مارس 25, 2024, 15:11