mirror of
				https://github.com/v2board/v2board.git
				synced 2025-11-04 03:11:46 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			55 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			55 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
namespace App\Console\Commands;
 | 
						|
 | 
						|
use App\Models\Plan;
 | 
						|
use App\Utils\Helper;
 | 
						|
use Illuminate\Console\Command;
 | 
						|
use App\Models\User;
 | 
						|
use Illuminate\Support\Facades\DB;
 | 
						|
 | 
						|
class ResetPassword extends Command
 | 
						|
{
 | 
						|
    protected $builder;
 | 
						|
    /**
 | 
						|
     * The name and signature of the console command.
 | 
						|
     *
 | 
						|
     * @var string
 | 
						|
     */
 | 
						|
    protected $signature = 'reset:password {email}';
 | 
						|
 | 
						|
    /**
 | 
						|
     * The console command description.
 | 
						|
     *
 | 
						|
     * @var string
 | 
						|
     */
 | 
						|
    protected $description = '重置用户密码';
 | 
						|
 | 
						|
    /**
 | 
						|
     * Create a new command instance.
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    public function __construct()
 | 
						|
    {
 | 
						|
        parent::__construct();
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Execute the console command.
 | 
						|
     *
 | 
						|
     * @return mixed
 | 
						|
     */
 | 
						|
    public function handle()
 | 
						|
    {
 | 
						|
        $user = User::where('email', $this->argument('email'))->first();
 | 
						|
        if (!$user) abort(500, '邮箱不存在');
 | 
						|
        $password = Helper::guid(false);
 | 
						|
        $user->password = password_hash($password, PASSWORD_DEFAULT);
 | 
						|
        $user->password_algo = null;
 | 
						|
        if (!$user->save()) abort(500, '重置失败');
 | 
						|
        $this->info("!!!重置成功!!!");
 | 
						|
        $this->info("新密码为:{$password},请尽快修改密码。");
 | 
						|
    }
 | 
						|
}
 |