Files
ServerCow_DNS_Panel/app/Console/Commands/ChangePassword.php
2021-05-13 11:20:17 +02:00

58 lines
1.3 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Http\Controllers\AuthController;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\App;
class ChangePassword extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'user:password:change {username}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Change a password';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
App::setLocale("en");
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$username = $this->argument('username');
$oAuthController = new AuthController();
$current_password = $this->secret("Please enter the current password");
$new_password = $this->secret("Please enter the new password");
$aReturn = $oAuthController->changePassword($username, $current_password, $new_password);
if ($aReturn["status"] == "error") {
$this->error($aReturn["message"]);
} else {
$this->info($aReturn["message"]);
}
}
}