Base solution for your next web application
Open Closed

JwtSecurityTokenHandler ValidateToken Exception (Bug?) #5561


User avatar
0
cangunaydin created

Hello, I am having an issue after my latest version upgrade (v5.6.2 angular + asp.net core .netframework full). Application is running without any problem after i log in but after some time probably after the token is expired. I am getting an exception here in this method.

Web.Core --> Authentication --> JwtBearer --> JwtSecurityTokenHandler.cs

public ClaimsPrincipal ValidateToken(string securityToken, TokenValidationParameters validationParameters, out SecurityToken validatedToken)

it is happening when it tries to delete the tokens expired. When try to save new user model to db unitofwork.complete method. It gives me an exception like this.

System.InvalidOperationException: 'The association between entity types 'User' and 'UserToken' has been severed but the relationship is either marked as 'Required' or is implicitly required because the foreign key is not nullable. If the dependent/child entity should be deleted when a required relationship is severed, then setup the relationship to use cascade deletes. Consider using 'DbContextOptionsBuilder.EnableSensitiveDataLogging' to see the key values.'

Also you can check this line from github, i think there can be a bug for removing the child entities.

<a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/f4a9488b7d3128e7471a9a13acefcae7210aef6b/src/Abp.ZeroCore/Authorization/Users/AbpUserStore.cs#L1306">https://github.com/aspnetboilerplate/as ... e.cs#L1306</a>

Any help would be appreciated. Thank you.


1 Answer(s)
  • User Avatar
    0
    cangunaydin created

    Hello. I figured it out. It is my bad. OnModelBuilder in dbcontext class i was giving data behavior restricted to the model that's why it couldn't update the db.