2023-01-26 09:30:33 -05:00
|
|
|
import { SystemConfigService } from '@app/domain';
|
2023-01-09 16:32:58 -05:00
|
|
|
import axios from 'axios';
|
|
|
|
import { Command, CommandRunner } from 'nest-commander';
|
|
|
|
|
|
|
|
@Command({
|
|
|
|
name: 'enable-password-login',
|
|
|
|
description: 'Enable password login',
|
|
|
|
})
|
|
|
|
export class EnablePasswordLoginCommand extends CommandRunner {
|
2023-01-26 09:30:33 -05:00
|
|
|
constructor(private configService: SystemConfigService) {
|
2023-01-09 16:32:58 -05:00
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(): Promise<void> {
|
2023-01-26 09:30:33 -05:00
|
|
|
const config = await this.configService.getConfig();
|
|
|
|
config.passwordLogin.enabled = true;
|
|
|
|
await this.configService.updateConfig(config);
|
2023-11-17 23:13:36 -05:00
|
|
|
await axios.post('http://localhost:3001/api/refresh-config');
|
2023-01-09 16:32:58 -05:00
|
|
|
console.log('Password login has been enabled.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Command({
|
|
|
|
name: 'disable-password-login',
|
|
|
|
description: 'Disable password login',
|
|
|
|
})
|
|
|
|
export class DisablePasswordLoginCommand extends CommandRunner {
|
2023-01-26 09:30:33 -05:00
|
|
|
constructor(private configService: SystemConfigService) {
|
2023-01-09 16:32:58 -05:00
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
|
|
|
async run(): Promise<void> {
|
2023-01-26 09:30:33 -05:00
|
|
|
const config = await this.configService.getConfig();
|
|
|
|
config.passwordLogin.enabled = false;
|
|
|
|
await this.configService.updateConfig(config);
|
2023-11-17 23:13:36 -05:00
|
|
|
await axios.post('http://localhost:3001/api/refresh-config');
|
2023-01-09 16:32:58 -05:00
|
|
|
console.log('Password login has been disabled.');
|
|
|
|
}
|
|
|
|
}
|