How to reset authorization token in asp.net after email changing? -
i have asp net web application. use asp net identity 2. if change email, webapi token stay valid. how can reset token? sorry bad language.
ok, issue token follows: 1) user call webapi method (get request {{host}}/token. method find user 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 "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);
Comments
Post a Comment