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