通过 php artisan root:password 重置管理员密码
This commit is contained in:
parent
90c1f0ed15
commit
d25ac50551
|
|
@ -55,7 +55,7 @@ class Kernel extends HttpKernel
|
|||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
],
|
||||
|
||||
'web' => [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
|
|
|
|||
|
|
@ -23,10 +23,11 @@ use Beike\Admin\View\Components\Form\Textarea;
|
|||
use Beike\Admin\View\Components\Header;
|
||||
use Beike\Admin\View\Components\NoData;
|
||||
use Beike\Admin\View\Components\Sidebar;
|
||||
use Beike\Console\Commands\ChangeRootPassword;
|
||||
use Beike\Console\Commands\GenerateDatabaseDict;
|
||||
use Beike\Console\Commands\GenerateSitemap;
|
||||
use Beike\Console\Commands\MakeRootAdminUser;
|
||||
use Beike\Console\Commands\MigrateFromOpenCart;
|
||||
use Beike\Console\Commands\Sitemap;
|
||||
use Beike\Models\AdminUser;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\View;
|
||||
|
|
@ -84,10 +85,11 @@ class AdminServiceProvider extends ServiceProvider
|
|||
{
|
||||
if ($this->app->runningInConsole()) {
|
||||
$this->commands([
|
||||
ChangeRootPassword::class,
|
||||
GenerateDatabaseDict::class,
|
||||
GenerateSitemap::class,
|
||||
MakeRootAdminUser::class,
|
||||
MigrateFromOpenCart::class,
|
||||
GenerateDatabaseDict::class,
|
||||
Sitemap::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* ChangeRootPassword.php
|
||||
*
|
||||
* @copyright 2023 beikeshop.com - All Rights Reserved
|
||||
* @link https://beikeshop.com
|
||||
* @author Edward Yang <yangjin@guangda.work>
|
||||
* @created 2023-02-13 20:56:16
|
||||
* @modified 2023-02-13 20:56:16
|
||||
*/
|
||||
|
||||
namespace Beike\Console\Commands;
|
||||
|
||||
use Beike\Models\AdminUser;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ChangeRootPassword extends Command
|
||||
{
|
||||
protected $signature = 'root:password';
|
||||
|
||||
protected $description = '修改后台Root账号(第一个管理员)';
|
||||
|
||||
/**
|
||||
* @throws \Throwable
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
$user = AdminUser::query()->first();
|
||||
$newPassword = $this->ask("请为管理员 {$user->email} 设置新密码:");
|
||||
|
||||
if (! $newPassword) {
|
||||
$this->info('请输入新密码');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$user->password = bcrypt($newPassword);
|
||||
$user->saveOrFail();
|
||||
$this->info('管理员密码设置成功!');
|
||||
}
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ namespace Beike\Console\Commands;
|
|||
use Beike\Services\SitemapService;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class Sitemap extends Command
|
||||
class GenerateSitemap extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::get('/test', function (){
|
||||
Route::get('/test', function () {
|
||||
echo __FILE__;
|
||||
})->name('test');
|
||||
|
|
|
|||
Loading…
Reference in New Issue