From ae8cfa40be05422978f929e095107049b6e44c70 Mon Sep 17 00:00:00 2001 From: xboard Date: Mon, 20 Nov 2023 09:38:14 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20php=20artisan=20reset:password=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E5=AF=86=E7=A0=81=E5=A2=9E=E5=8A=A0=E5=8F=AF=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E5=AF=86=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/ResetPassword.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/ResetPassword.php b/app/Console/Commands/ResetPassword.php index 37bc4f8..86e14a5 100644 --- a/app/Console/Commands/ResetPassword.php +++ b/app/Console/Commands/ResetPassword.php @@ -16,7 +16,7 @@ class ResetPassword extends Command * * @var string */ - protected $signature = 'reset:password {email}'; + protected $signature = 'reset:password {email} {password?}'; /** * The console command description. @@ -42,9 +42,10 @@ class ResetPassword extends Command */ public function handle() { + $password = $this->argument('password') ; $user = User::where('email', $this->argument('email'))->first(); if (!$user) abort(500, '邮箱不存在'); - $password = Helper::guid(false); + $password = $password ?? Helper::guid(false); $user->password = password_hash($password, PASSWORD_DEFAULT); $user->password_algo = null; if (!$user->save()) abort(500, '重置失败');