fix: person lookup failing due to legacy person_id_random field name
V3 CRUD returns 'id' as the random identifier, not 'person_id_random'. The person check and assignment were using the old field name, causing the 'no person record' alert even when the lookup returned valid data. Now checks person_rec.id ?? person_rec.person_id_random as a fallback for backwards compatibility.
This commit is contained in:
@@ -524,17 +524,15 @@
|
||||
})
|
||||
.then((person_response) => {
|
||||
// Safety Check: Ensure the response is valid and contains at least one record before accessing index 0.
|
||||
if (
|
||||
person_response &&
|
||||
person_response.length > 0 &&
|
||||
person_response[0].person_id_random
|
||||
) {
|
||||
// V3 CRUD returns 'id' as the random identifier; 'person_id_random' is a legacy field name.
|
||||
const person_rec = person_response?.[0];
|
||||
if (person_rec && (person_rec.id || person_rec.person_id_random)) {
|
||||
console.log(
|
||||
`Successfully loaded person for user_id_random (${user_id}):`,
|
||||
person_response[0]
|
||||
`Successfully loaded person (${user_id}):`,
|
||||
person_rec
|
||||
);
|
||||
person_obj = person_response[0];
|
||||
person_id = person_obj.person_id_random;
|
||||
person_obj = person_rec;
|
||||
person_id = person_rec.id ?? person_rec.person_id_random;
|
||||
|
||||
trigger = true; // Set trigger to true to indicate we can now sign in
|
||||
} else {
|
||||
@@ -544,7 +542,6 @@
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
// Once all promises are resolved, we can check if we have both user_id and person_id
|
||||
if (user_id && person_id) {
|
||||
console.log(`Successfully authenticated and loaded user and person records: user_id: ${user_id}, person_id: ${person_id}`);
|
||||
} else {
|
||||
@@ -623,17 +620,15 @@
|
||||
})
|
||||
.then((person_response) => {
|
||||
// Safety Check: Ensure the response is valid and contains at least one record before accessing index 0.
|
||||
if (
|
||||
person_response &&
|
||||
person_response.length > 0 &&
|
||||
person_response[0].person_id_random
|
||||
) {
|
||||
// V3 CRUD returns 'id' as the random identifier; 'person_id_random' is a legacy field name.
|
||||
const person_rec = person_response?.[0];
|
||||
if (person_rec && (person_rec.id || person_rec.person_id_random)) {
|
||||
console.log(
|
||||
`Successfully loaded person for user_id_random (${user_id}):`,
|
||||
person_response[0]
|
||||
`Successfully loaded person (${user_id}):`,
|
||||
person_rec
|
||||
);
|
||||
person_obj = person_response[0];
|
||||
person_id = person_obj.person_id_random;
|
||||
person_obj = person_rec;
|
||||
person_id = person_rec.id ?? person_rec.person_id_random;
|
||||
|
||||
trigger = true; // Set trigger to true to indicate we can now sign in
|
||||
} else {
|
||||
@@ -643,7 +638,6 @@
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
// Once all promises are resolved, we can check if we have both user_id and person_id
|
||||
if (user_id && person_id) {
|
||||
console.log(`Successfully authenticated and loaded user and person records: user_id: ${user_id}, person_id: ${person_id}`);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user