z-song / laravel-admin

Build a full-featured administrative interface in ten minutes
https://laravel-admin.org
MIT License
11.15k stars 2.82k forks source link

Unable to choose role when using php artisan admin:create-user #5665

Open milkice233 opened 2 years ago

milkice233 commented 2 years ago

Description:

The command admin:create-user should allow the user to specify the role of the newly created user. But it failed to show the role menu. The issue may originate from this line https://github.com/z-song/laravel-admin/blob/301d46dc1bd8d7a7da964f223f7b6f982ea51a1b/src/Console/CreateUserCommand.php#L43 and the bug may be introduced in the commit https://github.com/z-song/laravel-admin/commit/c4ad42e8753ef5642c94a79ca9259829041e6786

laravel-admin 提供了一个 admin:create-user 功能方便用 php artisan 创建 laravel-admin 用户,原先的版本中在输入新创建用户的用户名和密码后,会提示用户选择角色,但最近发现现在的 laravel-admin 将不会提示用户选择角色,而是将所有角色都赋予给该用户。看了下源码,可能是 https://github.com/z-song/laravel-admin/blob/301d46dc1bd8d7a7da964f223f7b6f982ea51a1b/src/Console/CreateUserCommand.php#L43 这行出现的问题,应该是 if (!empty($selectedRoles)) ,在 https://github.com/z-song/laravel-admin/commit/c4ad42e8753ef5642c94a79ca9259829041e6786 这个 commit 中引入了该 bug

Steps To Reproduce:

  1. Run php artisan admin:create-user

  2. After entering the new username & password, the CLI shows that the user has been successfully created, instead of showing the role menu.

  3. 运行 php artisan admin:create-user

  4. 输入完用户名和密码之后,直接提示创建成功,而不是要求用户选择角色。此时去管理后台看新创建的用户,发现该用户拥有所有角色。