Another Fix
This commit is contained in:
parent
cdaf08b449
commit
218d9205c4
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue