I have asp net web application. It use asp net identity 2. If i change my email, my webapi token stay valid. How i can reset token? Sorry for my bad language.
Ok, I issue a token as follows: 1) User call webapi method (get request for {{host}}/token. Method find this user from usercontext (username,password) in user repositories. if user found, system generate token.
var tokenExpiration = TimeSpan.FromDays(1);
var ticket = accountManager.generateTicket(user.UserName, tokenExpiration);
if (ticket != null){
var token = Startup.OAuthOptions.AccessTokenFormat.Protect(ticket);
return new TokenResponse{
Token = token,
TokenExpires = tokenExpiration.TotalSeconds
};
}
Code for "generateTicket":
ClaimsIdentity identity = new ClaimsIdentity(OAuthDefaults.AuthenticationType);
identity.AddClaim(new Claim(ClaimTypes.Name, userName));
var props = new AuthenticationProperties()
{
IssuedUtc = DateTime.UtcNow,
ExpiresUtc = DateTime.UtcNow.Add(tokenExpiration),
};
return new AuthenticationTicket(identity, props);