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
|
// TODO: Implement updateName method, Current implementation resets extension for some reason
|
||||||
|
|
||||||
async updateExtPassword(ext, password) {
|
async updateExtPassword(ext, oldName, password) {
|
||||||
const query = gql`
|
const query = gql`
|
||||||
mutation updateExt($ext: ID!, $name: String, $password: String) {
|
mutation updateExt($ext: ID!, $name: String, $password: String) {
|
||||||
updateExtension(input: {
|
updateExtension(input: {
|
||||||
name: test
|
name: $name
|
||||||
extensionId: $ext
|
extensionId: $ext
|
||||||
extPassword: $password
|
extPassword: $password
|
||||||
}) {
|
}) {
|
||||||
|
|
@ -190,7 +190,8 @@ class FreepbxManager {
|
||||||
}`;
|
}`;
|
||||||
const variables = {
|
const variables = {
|
||||||
ext,
|
ext,
|
||||||
password
|
password,
|
||||||
|
name: oldName
|
||||||
};
|
};
|
||||||
return await this.pbxCall(query, variables);
|
return await this.pbxCall(query, variables);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ module.exports.execute = async (interaction) => {
|
||||||
// console.log(JSON.stringify(interaction, null, 2));
|
// console.log(JSON.stringify(interaction, null, 2));
|
||||||
const newPassword = interaction.fields.getTextInputValue('newPassword');
|
const newPassword = interaction.fields.getTextInputValue('newPassword');
|
||||||
let passwordToSet = newPassword;
|
let passwordToSet = newPassword;
|
||||||
|
let oldName = extData.fetchExtension.user.name;
|
||||||
if (!newPassword || newPassword.trim() === '') {
|
if (!newPassword || newPassword.trim() === '') {
|
||||||
// Generate password based on process.env.PASSWORD_LENGTH and process.env.PASSWORD_CHARS or default to 32 alphanumeric with caps
|
// 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;
|
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('');
|
passwordToSet = Array.from({ length }, () => chars.charAt(Math.floor(Math.random() * chars.length))).join('');
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
//const updated = await fpbx.updateExtPassword(lookup.extension, passwordToSet);
|
const updated = await fpbx.updateExtPassword(lookup.extension, oldName, passwordToSet);
|
||||||
const updated = await fpbx.updateExtName(lookup.extension, passwordToSet);
|
//const updated = await fpbx.updateExtName(lookup.extension, passwordToSet);
|
||||||
console.log(updated)
|
console.log(updated)
|
||||||
await interaction.editReply({ content: `Your extension password has been reset successfully! Your new password is: ||\`${passwordToSet}\`||`, ephemeral: true });
|
await interaction.editReply({ content: `Your extension password has been reset successfully! Your new password is: ||\`${passwordToSet}\`||`, ephemeral: true });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue