protected virtual async Task <IEnumerable <Claim> > SetAccountPhoneAsync(TKey userID, IEnumerable <Claim> claims) { var phone = claims.FirstOrDefault(x => x.Type == Constants.ClaimTypes.PhoneNumber); if (phone != null) { var userPhone = await userManager.GetPhoneNumberAsync(userID); if (userPhone == null) { // if this fails, then presumably the phone is already associated with another account // so ignore the error and let the claim pass thru var result = await userManager.SetPhoneNumberAsync(userID, phone.Value); if (result.Succeeded) { var phone_verified = claims.FirstOrDefault(x => x.Type == Constants.ClaimTypes.PhoneNumberVerified); if (phone_verified != null && phone_verified.Value == "true") { var token = await userManager.GenerateChangePhoneNumberTokenAsync(userID, phone.Value); await userManager.ChangePhoneNumberAsync(userID, phone.Value, token); } var phoneClaims = new string[] { Constants.ClaimTypes.PhoneNumber, Constants.ClaimTypes.PhoneNumberVerified }; return(claims.Where(x => !phoneClaims.Contains(x.Type))); } } } return(claims); }