Base solution for your next web application
Open Closed

Exception using the E-Mail Based Tenant Login #11278


User avatar
0
elecosoftseservice created
  • What is your product version? v11.0.1
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .Net Core 6

I've been trying to implement E-mail based tenant login, and have used the code in these articles below:

https://docs.aspnetzero.com/en/aspnet-core-angular/latest/Core-Angular-Sign-In-Without-Specifying-Tenant https://support.aspnetzero.com/QA/Questions/10855/remove-tenant-from-the-login-screen---You-are-not-logged-in-as-a-host-user

When trying this out, I get past the code which Logs in the user, but an exception is raised further down:

TokenAuthController.cs CreateJwtClaims():

await _userManager.AddTokenValidityKeyAsync( user, tokenValidityKey, expirationDate );

System.InvalidOperationException: The navigation 'User.Tokens' cannot be loaded because the entity is not being tracked. Navigations can only be loaded for tracked entities. at Microsoft.EntityFrameworkCore.Internal.EntityFinder1.<LoadAsync>d__11.MoveNext() at Abp.EntityFrameworkCore.Repositories.EfCoreRepositoryBase3.<EnsureCollectionLoadedAsync>d__451.MoveNext() at Abp.Domain.Repositories.RepositoryExtensions.<EnsureCollectionLoadedAsync>d__03.MoveNext() at Abp.Authorization.Users.AbpUserStore2.<>c__DisplayClass170_0.<<AddTokenValidityKeyAsync>b__0>d.MoveNext() at Abp.Domain.Uow.UnitOfWorkManagerExtensions.<WithUnitOfWorkAsync>d__1.MoveNext() at Abp.Authorization.Users.AbpUserStore2.<AddTokenValidityKeyAsync>d__170.MoveNext() at Abp.Authorization.Users.AbpUserManager`2.

Any ideas on what could be causing this?


10 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    @elecosoftseservice we will try to reproduce it and inform you.

  • User Avatar
    0
    m.aliozkaya created
    Support Team

    Hi @elecosoftseservice

    I followed this tutorial in fresh solution and same version but I couldn't reproduce it. May you have disabled the entity framework core tracking?

  • User Avatar
    0
    elecosoftseservice created

    Hi, many thanks for checking this through so quickly.

    I haven't changed EF tracking from the default in the solution.

    I'm unsure of the inner workings of the Authentication framework to know what the exception message is telling me is going on, or where to look to debug this further. Can you suggest maybe where to look or what this code is trying to do please?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @elecosoftseservice

    Is it possible to share your projetc via email with [email protected] ? We can find the problem faster by looking at your project.

  • User Avatar
    0
    elecosoftseservice created

    Hi,

    Unfortunately I'm unable to send across the project code as it's the companies IP and would likely have to go through Legal to get an NDA drawn up.

    If you're able to give some pointers though, that would be very helpful.

    I'm unsure of the inner workings of the Authentication framework to know what the exception message is telling me is going on, or where to look to debug this further. Can you suggest maybe where to look or what this code is trying to do please?

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    It is hard to detect the problem without looking at the code because we don't get any error when we make same implementation on a not modified project. Would it be possible to arrange an online meeting and check the problem ?

  • User Avatar
    0
    elecosoftseservice created

    Hi,

    Yes, if we could arrange that please it would be a great help.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Could you send an email to [email protected] including your timezone ?

  • User Avatar
    0
    elecosoftseservice created

    Thankyou, Email sent.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks, we will arrange the meeting via email.