Open Closed

AddTokenValidityKeyAsync not saving in AbpUserToken #11216


0
mark.montesa created
  • What is your product version? 8.2
  • What is your product type (Angular or MVC)? Angular
  • What is product framework type (.net framework or .net core)? .net core

Hi, just found out that AddTokenValidityKeyAsync method is not saving the token on the AbpUserToken table. May I have some input on why it suddenly stop working?

Thanks.


21 Answer(s)
  • 0
    ismcagdas created
    Support Team

    Hi @mark.montesa

    How can we reproduce this problem ? Could you share the steps ?

  • 0
    mark.montesa created

    We have multitenant setting with different database and multi instance on our production. We are not able to save token validity on database using AddTokenValidityKeyAsync method.

  • 0
    ismcagdas created
    Support Team

    Hi,

    This method basically adds the token to user.Tokens list. Could you share how do you use it in your project ? Is it the default usage in TokenAuthController's CreateJwtClaims method ?

  • 0
    mark.montesa created

    Hi,

    "This method basically adds the token to user.Tokens list." --- Yes that correct it adds the token to user.Tokens list, but the weird thing it does not reflect on the UserToken table.

    " Is it the default usage in TokenAuthController's CreateJwtClaims method ?" --- Yes were using the default CreateJwtClaims with no update on the method.

  • 0
    ismcagdas created
    Support Team

    Hi @mark.montesa

    Sorry for the late reply. We will check this and get back to you in a short time.

  • 0
    m.aliozkaya created
    Support Team

    Hi @mark.montesa

    I tested in your version, it is working. Could you give me more information?

  • 0
    mark.montesa created

    hi m.aliozkaya,

    Yes already tested it on vanilla version of ANZ 8.2 and its working. Do you have any idea on what possible changes we have made that makes it stop working. The problem is we cannot track the update we have that make it stop working. Any inputs that put us on the right path for debugging the issue is very appreciated thanks.

    We have initially have ANZ 7 then update it to 8.2

    Thanks

  • 1
    ismcagdas created
    Support Team

    Hi @mark.montesa

    Is it possible to share your project with us via email ? We can cehck your source code and try to find the problem. It is hard to detect the problem without seeing the source code.

  • 0
    mark.montesa created

    hi @ismcagdas,

    I'll share it to you via email. May I know your email address.

  • 0
    m.aliozkaya created
    Support Team

    Hi @mark.montesa

    You can send your source code to this email: info@aspnetzero.com

  • 0
    mark.montesa created

    Hi m.aliozkaya I just sent a copy of source code on info@aspnetzero.com.

    Thanks in advance

  • 0
    ismcagdas created
    Support Team

    Thanks @mark.montesa we will check it

  • 0
    m.aliozkaya created
    Support Team

    Hi @mark.montesa,

    I can't migrate migrations to my local database. I have errors about same tables. Like AbpWebhookEvents table exists in your database.

  • 0
    mark.montesa created

    Hi @m.aliozkaya,

    Hi sorry about that. Ill compile our migrations files then will send it to you. Ill create a single migration file. You can disregard the existing migration files.

    Thanks,

  • 0
    ismcagdas created
    Support Team

    Hi,

    Thanks, we got the migration file and will cehck it.

  • 0
    mark.montesa created

    hi @m.aliozkaya, @ismcagdas,

    Any update on this. Any feedback is appreciated thanks.

  • 0
    ismcagdas created
    Support Team

    Hi @mark.montesa

    We checked the problem but we couldn't identify the problem yet.

  • 0
    mark.montesa created

    hi @m.aliozkaya, @ismcagdas,

    any findings you can share with us? as of now I put a code that will force saving of AbpUserTokens on the database.

    thanks

  • 0
    ismcagdas created
    Support Team

    Hi @mark.montesa

    I have found the problem, it is because of the line below in your DbContext;

    ChangeTracker.AutoDetectChangesEnabled = false;
    

    Since the token is added to the Tokens collection of User entity, the change is not detected becaue of this line.

  • 0
    mark.montesa created

    Hi @ismcagdas,

    Thank you for your findings. We will check it.

  • 0
    ismcagdas created
    Support Team

    Thanks.