protected virtual void SetAccountPhone(Guid accountID, ref IEnumerable <Claim> claims) { var phone = ClaimsExtensions.GetValue(claims, Constants.ClaimTypes.PhoneNumber); if (phone != null) { var acct = userAccountService.GetByID(accountID); if (acct.MobilePhoneNumber == null) { try { var phone_verified = ClaimsExtensions.GetValue(claims, Constants.ClaimTypes.PhoneNumberVerified); if (phone_verified != null && phone_verified == "true") { userAccountService.SetConfirmedMobilePhone(acct.ID, phone); } else { userAccountService.ChangeMobilePhoneRequest(acct.ID, phone); } var phoneClaims = new string[] { Constants.ClaimTypes.PhoneNumber, Constants.ClaimTypes.PhoneNumberVerified }; claims = claims.Where(x => !phoneClaims.Contains(x.Type)); } catch (ValidationException) { // presumably the phone is already associated with another account // so eat the validation exception and let the claim pass thru } } } }
protected virtual void SetAccountEmail(Guid accountID, ref IEnumerable <Claim> claims) { var email = ClaimsExtensions.GetValue(claims, Constants.ClaimTypes.Email); if (email != null) { var acct = userAccountService.GetByID(accountID); if (acct.Email == null) { try { var email_verified = ClaimsExtensions.GetValue(claims, Constants.ClaimTypes.EmailVerified); if (email_verified != null && email_verified == "true") { userAccountService.SetConfirmedEmail(acct.ID, email); } else { userAccountService.ChangeEmailRequest(acct.ID, email); } var emailClaims = new string[] { Constants.ClaimTypes.Email, Constants.ClaimTypes.EmailVerified }; claims = claims.Where(x => !emailClaims.Contains(x.Type)); } catch (ValidationException) { // presumably the email is already associated with another account // so eat the validation exception and let the claim pass thru } } } }