fix: sign-in broken due to wrong field name on auth response

The /user/authenticate endpoint returns 'user_id' not 'user_id_random'.
Both auth flows (user_id+auth_key and username+password) were checking
user_response?.user_id_random, which was always undefined, causing the
user_id to never be set and falling through to the email lookup fallback.

Fixed both .then() handlers to check user_response?.user_id and assign
user_obj.user_id.
This commit is contained in:
Scott Idem
2026-03-06 22:39:16 -05:00
parent e9527cdcd5
commit 79457103de

View File

@@ -469,13 +469,13 @@
}) })
.then((user_response) => { .then((user_response) => {
// console.log(`HERE:`, user_response); // console.log(`HERE:`, user_response);
if (user_response?.user_id_random) { if (user_response?.user_id) {
console.log( console.log(
`Successfully authenticated in with User ID and User Auth Key: ${user_response.username}`, `Successfully authenticated in with User ID and User Auth Key: ${user_response.username}`,
user_response user_response
); );
user_obj = user_response; // Store the user object for later use user_obj = user_response; // Store the user object for later use
user_id = user_obj.user_id_random; // Use the user_id_random for further API calls user_id = user_obj.user_id; // Use the user_id for further API calls
// person_id = user_obj.person_id_random; // person_id = user_obj.person_id_random;
} else { } else {
alert('Failed to authenticate: ' + (user_response?.error || 'Unknown error')); alert('Failed to authenticate: ' + (user_response?.error || 'Unknown error'));
@@ -576,13 +576,13 @@
log_lvl: 1 log_lvl: 1
}) })
.then((user_response) => { .then((user_response) => {
if (user_response?.user_id_random) { if (user_response?.user_id) {
console.log( console.log(
`Successfully authenticated in with Username (${user_response.username}) and Password:`, `Successfully authenticated in with Username (${user_response.username}) and Password:`,
user_response user_response
); );
user_obj = user_response; // Store the user object for later use user_obj = user_response; // Store the user object for later use
user_id = user_obj.user_id_random; // Use the user_id_random for further API calls user_id = user_obj.user_id; // Use the user_id for further API calls
// person_id = user_obj.person_id_random; // person_id = user_obj.person_id_random;
} else { } else {
alert('Failed to authenticate: ' + (user_response?.error || 'Unknown error')); alert('Failed to authenticate: ' + (user_response?.error || 'Unknown error'));