Starts in:
2 DAYS
16 HRS
10 MIN
16 SEC
Starts in:
2 D
16 H
10 M
16 S
Open Closed

CurrentUser.UserName is null #2310


User avatar
0
uyarbtrlp created
  • ABP Framework version: v4.4.3
  • UI type: MVC
  • DB provider: EF Core
  • Module Template: yes
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hello ABP,

I have created a new solution with version of 4.4.3 like described in your documentation.

abp new Acme.IssueManagement -t module-pro -v 4.4.3

I have used CurrentUser.UserName on SampleAppService which comes from default template for taking the username. I saw the username was null. Other values were fine.

If I try on developer tools by using "abp.currentUser", I can see the username.

I have faced this issue on my application and I wanted to be sure whether the cause of the problem was related with me or not. Is that kind a bug or am I missing somethings?

Thanks.


4 Answer(s)
  • User Avatar
    0
    cotur created

    Hello @uyarbtrlp

    I could not reproduce your problem.

    I have created a new module-pro template and run with debug mode. Then I am able to see the currentUser username.

  • User Avatar
    0
    uyarbtrlp created

    Have you tried on Web.Unified which is Single (Unified) Application Scenario? When I runned identity, web.host and http.host separately (which is Separated Deployment & Databases Scenario), I got that problem. Web.Unified works properly.

  • User Avatar
    0
    cotur created

    Hello @uyarbtrlp

    Yes, I've reproduced that strange problem.

    It looks like we have missing configuration related with identity claims in our module-pro template.

    This is only development time problem of course, when you test it with normal application it will work without problem. (not host appilations in your module solution)

    Thanks for your feedback, we will investigate and fix the problem. Will reply here again with the fix.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    Try this

    .AddJwtBearer(options =>
    {
        options.Authority = configuration["AuthServer:Authority"];
        options.RequireHttpsMetadata = Convert.ToBoolean(configuration["AuthServer:RequireHttpsMetadata"]);
        options.Audience = "IssueManagement";
    
        options.SecurityTokenValidators.Clear();
        options.SecurityTokenValidators.Add(new JwtSecurityTokenHandler
        {
            InboundClaimTypeMap =
            {
                ["preferred_username"] = ClaimTypes.Name
            }
        });
    });
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06