refactor: usermod account lock logic
parent
ec343d541c
commit
d4c740206d
|
@ -45,7 +45,10 @@ export default class Usermod extends Command {
|
||||||
try {
|
try {
|
||||||
await this.client.commands.get('notify')
|
await this.client.commands.get('notify')
|
||||||
.run(message, [account.username, ...`Changing your username from \`${account.username}\` to \`${value}\`. DN/C`.split(' ')]);
|
.run(message, [account.username, ...`Changing your username from \`${account.username}\` to \`${value}\`. DN/C`.split(' ')]);
|
||||||
await this.client.util.exec(`lock ${account.username}`);
|
if (!account.locked) {
|
||||||
|
await account.updateOne({ locked: true });
|
||||||
|
await this.client.util.exec(`lock ${account.username}`);
|
||||||
|
}
|
||||||
|
|
||||||
await this.client.util.exec(`usermod -l ${value} ${account.username}`);
|
await this.client.util.exec(`usermod -l ${value} ${account.username}`);
|
||||||
await this.client.util.exec(`usermod -d /home/${value} ${value}`);
|
await this.client.util.exec(`usermod -d /home/${value} ${value}`);
|
||||||
|
@ -59,10 +62,13 @@ export default class Usermod extends Command {
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
await this.client.commands.get('notify')
|
await this.client.commands.get('notify')
|
||||||
.run(message, [account.username, ...'Your username change was unsuccessful. Please contact a Technician for more details.'.split(' ')]);
|
.run(message, [account.username, ...'Your username change was unsuccessful. Please contact a Technician for more details.'.split(' ')]);
|
||||||
this.error(message.channel, 'Failed to modify username.');
|
await this.client.util.handleError(error);
|
||||||
return this.client.util.handleError(error);
|
return this.error(message.channel, 'Failed to modify username. Please check <#595788220764127272> for more information.');
|
||||||
} finally {
|
} finally {
|
||||||
await this.client.util.exec(`unlock ${account.username}`);
|
if (account.locked) {
|
||||||
|
await this.client.util.exec(`unlock ${account.username}`);
|
||||||
|
await account.updateOne({ locked: false });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modifyingPropertyResponse.delete();
|
modifyingPropertyResponse.delete();
|
||||||
|
|
Loading…
Reference in New Issue