12345678910111213141516171819202122232425262728293031323334 |
- <?php
- declare (strict_types = 1);
- namespace app\command\auth;
- use app\service\admin\auth\LoginService;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Option;
- use think\console\Output;
- class Resetpassword extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('reset')
- ->addOption('password', 'p', Option::VALUE_OPTIONAL, 'please enter the password you will set.')
- ->setDescription('the reset administrator password command');
- }
- protected function execute(Input $input, Output $output)
- {
- if ($input->hasOption('password')) {
- $password = $input->getOption('password');
- $password = $password ?: '123456';
- } else {
- $password = '123456';
- }
- LoginService::resetAdministratorPassword($password);
- // 指令输出
- $output->writeln('password reset success');
- }
- }
|