public async Task <OperationResult <JwtToken> > ConfirmEmailChange(string userId, string email, string token) { User user = await userManager.FindByIdAsync(userId); OperationResult result = await emailConfirmationService.ConfirmEmailChange(user, email, token); if (!result.IsValid) { return(result.Cast <JwtToken>()); } // the information in the user's token is stale after the e-mail change // - generate and send a new token with current user info var encodedToken = tokenService.BuildToken(user); return(OperationResult <JwtToken> .Valid(new JwtToken(encodedToken))); }