Another Fix

This commit is contained in:
Christopher Cookman 2025-11-18 12:20:56 -07:00
parent cdaf08b449
commit 218d9205c4
2 changed files with 7 additions and 5 deletions

View file

@ -176,11 +176,11 @@ class FreepbxManager {
}
// TODO: Implement updateName method, Current implementation resets extension for some reason
async updateExtPassword(ext, password) {
async updateExtPassword(ext, oldName, password) {
const query = gql`
mutation updateExt($ext: ID!, $name: String, $password: String) {
updateExtension(input: {
name: test
name: $name
extensionId: $ext
extPassword: $password
}) {
@ -190,7 +190,8 @@ class FreepbxManager {
}`;
const variables = {
ext,
password
password,
name: oldName
};
return await this.pbxCall(query, variables);
}

View file

@ -16,6 +16,7 @@ module.exports.execute = async (interaction) => {
// console.log(JSON.stringify(interaction, null, 2));
const newPassword = interaction.fields.getTextInputValue('newPassword');
let passwordToSet = newPassword;
let oldName = extData.fetchExtension.user.name;
if (!newPassword || newPassword.trim() === '') {
// Generate password based on process.env.PASSWORD_LENGTH and process.env.PASSWORD_CHARS or default to 32 alphanumeric with caps
const length = parseInt(process.env.PASSWORD_LENGTH) || 32;
@ -23,8 +24,8 @@ module.exports.execute = async (interaction) => {
passwordToSet = Array.from({ length }, () => chars.charAt(Math.floor(Math.random() * chars.length))).join('');
}
try {
//const updated = await fpbx.updateExtPassword(lookup.extension, passwordToSet);
const updated = await fpbx.updateExtName(lookup.extension, passwordToSet);
const updated = await fpbx.updateExtPassword(lookup.extension, oldName, passwordToSet);
//const updated = await fpbx.updateExtName(lookup.extension, passwordToSet);
console.log(updated)
await interaction.editReply({ content: `Your extension password has been reset successfully! Your new password is: ||\`${passwordToSet}\`||`, ephemeral: true });
} catch (error) {