Fixes for username and password sign in! Quick save while Gemini still working.

This commit is contained in:
Scott Idem
2026-01-15 11:28:57 -05:00
parent 380e80ed7d
commit b88d5fbabf
3 changed files with 63 additions and 19 deletions

View File

@@ -115,15 +115,15 @@ export async function load_ae_obj_li__person({
} }
if (enabled === 'enabled') { if (enabled === 'enabled') {
search_query.and.push({ field: 'enabled', op: 'eq', value: true }); search_query.and.push({ field: 'enable', op: 'eq', value: true });
} else if (enabled === 'not_enabled') { } else if (enabled === 'not_enabled') {
search_query.and.push({ field: 'enabled', op: 'eq', value: false }); search_query.and.push({ field: 'enable', op: 'eq', value: false });
} }
if (hidden === 'hidden') { if (hidden === 'hidden') {
search_query.and.push({ field: 'hidden', op: 'eq', value: true }); search_query.and.push({ field: 'hide', op: 'eq', value: true });
} else if (hidden === 'not_hidden') { } else if (hidden === 'not_hidden') {
search_query.and.push({ field: 'hidden', op: 'eq', value: false }); search_query.and.push({ field: 'hide', op: 'eq', value: false });
} }
promise = api.search_ae_obj_v3({ promise = api.search_ae_obj_v3({

View File

@@ -33,6 +33,14 @@ export async function auth_ae_obj__username_password({
const endpoint = '/user/authenticate'; const endpoint = '/user/authenticate';
// Prepare API config with correct headers
const use_api_cfg = { ...api_cfg, headers: { ...api_cfg.headers } };
if (account_id) {
use_api_cfg.headers['x-account-id'] = account_id;
delete use_api_cfg.headers['x-no-account-id'];
params['account_id'] = account_id;
}
if (null_account_id) { if (null_account_id) {
params['null_account_id'] = true; params['null_account_id'] = true;
} }
@@ -45,7 +53,7 @@ export async function auth_ae_obj__username_password({
ae_promises.auth__username_password = await api ae_promises.auth__username_password = await api
.get_object({ .get_object({
api_cfg: api_cfg, api_cfg: use_api_cfg,
endpoint: endpoint, endpoint: endpoint,
params: params, params: params,
// data: {}, // data: {},
@@ -103,6 +111,14 @@ export async function auth_ae_obj__user_id_user_auth_key({
const endpoint = '/user/authenticate'; const endpoint = '/user/authenticate';
// Prepare API config with correct headers
const use_api_cfg = { ...api_cfg, headers: { ...api_cfg.headers } };
if (account_id) {
use_api_cfg.headers['x-account-id'] = account_id;
delete use_api_cfg.headers['x-no-account-id'];
params['account_id'] = account_id;
}
params['user_id'] = user_id; // Required params['user_id'] = user_id; // Required
params['auth_key'] = user_auth_key; // Required params['auth_key'] = user_auth_key; // Required
params['inc_jwt'] = true; // Request a JWT in the response params['inc_jwt'] = true; // Request a JWT in the response
@@ -112,7 +128,7 @@ export async function auth_ae_obj__user_id_user_auth_key({
ae_promises.auth__user_id_user_key = await api ae_promises.auth__user_id_user_key = await api
.get_object({ .get_object({
api_cfg: api_cfg, api_cfg: use_api_cfg,
endpoint: endpoint, endpoint: endpoint,
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl
@@ -170,8 +186,17 @@ export async function send_email_auth_ae_obj__user_id({
root_url: base_url, root_url: base_url,
key_param_name: key_param_name key_param_name: key_param_name
}; };
// Prepare API config with correct headers
const use_api_cfg = { ...api_cfg, headers: { ...api_cfg.headers } };
if (account_id) {
use_api_cfg.headers['x-account-id'] = account_id;
delete use_api_cfg.headers['x-no-account-id'];
params['account_id'] = account_id;
}
ae_promises.auth_key__send_email = await api.get_object({ ae_promises.auth_key__send_email = await api.get_object({
api_cfg: api_cfg, api_cfg: use_api_cfg,
endpoint: email_auth_key_endpoint, endpoint: email_auth_key_endpoint,
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl
@@ -246,15 +271,24 @@ export async function qry_ae_obj_li__user_email({
const endpoint = '/user/lookup_email'; const endpoint = '/user/lookup_email';
// Prepare API config with correct headers
const use_api_cfg = { ...api_cfg, headers: { ...api_cfg.headers } };
if (account_id) {
use_api_cfg.headers['x-account-id'] = account_id;
delete use_api_cfg.headers['x-no-account-id'];
params['account_id'] = account_id;
}
params['email'] = email; // Required params['email'] = email; // Required
params['null_account_id'] = null_account_id || false; params['null_account_id'] = null_account_id || false;
if (log_lvl > 1) { if (log_lvl > 1) {
console.log(`qry_ae_obj_li__user_email() - params:`, params); console.log(`qry_ae_obj_li__user_email() - params:`, params);
} }
ae_promises.qry__user_email = await api ae_promises.qry__user_email = await api
.get_object({ .get_object({
api_cfg: api_cfg, api_cfg: use_api_cfg,
endpoint: endpoint, endpoint: endpoint,
params: params, params: params,
log_lvl: log_lvl log_lvl: log_lvl

View File

@@ -220,7 +220,7 @@
handle_send_auth_email({ handle_send_auth_email({
user_id: user_response.user_id_random user_id: user_response.user_id_random
}); });
} else if (user_response.length > 0) { } else if (user_response && user_response.length > 0) {
console.log(`Multiple users found for email:`, user_response); console.log(`Multiple users found for email:`, user_response);
handle_send_auth_email({ handle_send_auth_email({
user_id: user_response[0].user_id_random user_id: user_response[0].user_id_random
@@ -452,7 +452,7 @@
}) })
.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_random) {
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
@@ -461,7 +461,7 @@
user_id = user_obj.user_id_random; // Use the user_id_random for further API calls user_id = user_obj.user_id_random; // Use the user_id_random 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); alert('Failed to authenticate: ' + (user_response?.error || 'Unknown error'));
} }
}) })
.then((response) => { .then((response) => {
@@ -494,12 +494,18 @@
for_obj_type: 'account', for_obj_type: 'account',
for_obj_id: $ae_loc.account_id, for_obj_id: $ae_loc.account_id,
qry_user_id: user_id, // The user_id_random from the above authentication qry_user_id: user_id, // The user_id_random from the above authentication
enabled: 'all',
hidden: 'all',
// params_json: params_json, // params_json: params_json,
// params: params, // params: params,
log_lvl: 1 log_lvl: 1
}) })
.then((person_response) => { .then((person_response) => {
if (person_response[0].person_id_random) { if (
person_response &&
person_response.length > 0 &&
person_response[0].person_id_random
) {
console.log( console.log(
`Successfully loaded person for user_id_random (${user_id}):`, `Successfully loaded person for user_id_random (${user_id}):`,
person_response[0] person_response[0]
@@ -510,8 +516,7 @@
trigger = true; // Set trigger to true to indicate we can now sign in trigger = true; // Set trigger to true to indicate we can now sign in
} else { } else {
alert( alert(
'Failed to load person information: ' + 'Failed to load person information. No person record found for this user.'
person_response.error
); );
} }
}) })
@@ -550,7 +555,7 @@
log_lvl: 1 log_lvl: 1
}) })
.then((user_response) => { .then((user_response) => {
if (user_response.user_id_random) { if (user_response?.user_id_random) {
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
@@ -559,7 +564,7 @@
user_id = user_obj.user_id_random; // Use the user_id_random for further API calls user_id = user_obj.user_id_random; // Use the user_id_random 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); alert('Failed to authenticate: ' + (user_response?.error || 'Unknown error'));
} }
}) })
.then((response) => { .then((response) => {
@@ -592,12 +597,18 @@
for_obj_type: 'account', for_obj_type: 'account',
for_obj_id: $ae_loc.account_id, for_obj_id: $ae_loc.account_id,
qry_user_id: user_id, // The user_id_random from the above authentication qry_user_id: user_id, // The user_id_random from the above authentication
enabled: 'all',
hidden: 'all',
// params_json: params_json, // params_json: params_json,
// params: params, // params: params,
log_lvl: 1 log_lvl: 1
}) })
.then((person_response) => { .then((person_response) => {
if (person_response[0].person_id_random) { if (
person_response &&
person_response.length > 0 &&
person_response[0].person_id_random
) {
console.log( console.log(
`Successfully loaded person for user_id_random (${user_id}):`, `Successfully loaded person for user_id_random (${user_id}):`,
person_response[0] person_response[0]
@@ -608,8 +619,7 @@
trigger = true; // Set trigger to true to indicate we can now sign in trigger = true; // Set trigger to true to indicate we can now sign in
} else { } else {
alert( alert(
'Failed to load person information: ' + 'Failed to load person information. No person record found for this user.'
person_response.error
); );
} }
}) })