Guard against phone entries missing value property

This commit is contained in:
Adam Moussa 2026-05-11 13:57:30 -04:00
parent eae9655c74
commit 31f1ba15ef

View file

@ -146,11 +146,9 @@ function extractUserFields(googleUser) {
let phone = "";
if (googleUser.phones && googleUser.phones.length > 0) {
const workPhone = googleUser.phones.find((p) => p.type === "work");
const primaryPhone = googleUser.phones.find((p) => p.primary) || googleUser.phones[0];
phone = workPhone
? workPhone.value
: primaryPhone.value || "";
const workPhone = googleUser.phones.find((p) => p.type === "work" && p.value);
const primaryPhone = googleUser.phones.find((p) => p.primary && p.value) || googleUser.phones.find((p) => p.value);
phone = (workPhone || primaryPhone || {}).value || "";
}
return { email, jobTitle, phone };