Adding a Change Password option.

This commit is contained in:
Scott Idem
2025-04-11 13:04:03 -04:00
parent deef453580
commit bb84b4bbb4
3 changed files with 82 additions and 2 deletions

View File

@@ -279,3 +279,62 @@ export async function qry_ae_obj_li__user_email(
}
return ae_promises.qry__user_email;
}
// Change user password
// endpoint: PATCH /user/{user_id}/change_password
// params:
// data_kv: password (the new password)
// Updated 2025-04-11
export async function auth_ae_obj__user_id_change_password(
{
api_cfg,
account_id,
user_id,
password,
params = {},
log_lvl = 0
}: {
api_cfg: any,
account_id: string,
user_id: string,
password: string,
params?: key_val,
log_lvl?: number
}
) {
if (log_lvl) {
console.log(`*** auth_ae_obj__user_id_change_password() *** account_id=${account_id} user_id=${user_id}`);
}
let endpoint = `/user/${user_id}/change_password`;
params['user_id'] = user_id; // Required
if (log_lvl > 1) {
console.log(`auth_ae_obj__user_id_change_password() - params:`, params);
}
ae_promises.change_password__user_id = await api.patch_object({
api_cfg: api_cfg,
endpoint: endpoint,
params: params,
data: { password: password },
log_lvl: log_lvl
})
.then(async function (change_password_result) {
if (change_password_result) {
return change_password_result;
} else {
console.log('No results returned.');
return null;
}
})
.catch(function (error) {
console.log('No results returned or failed.', error);
});
if (log_lvl) {
console.log('ae_promises.change_password__user_id:', ae_promises.change_password__user_id);
}
return ae_promises.change_password__user_id;
}