mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 12:30:49 +08:00
fix create user
This commit is contained in:
@@ -51,7 +51,7 @@ class UserResource extends Resource
|
||||
Forms\Components\TextInput::make('password')->password()->required()->visibleOn(Pages\CreateUser::class),
|
||||
Forms\Components\TextInput::make('password_confirmation')->password()->required()->same('password')->visibleOn(Pages\CreateUser::class),
|
||||
Forms\Components\TextInput::make('id')->integer(),
|
||||
Forms\Components\Select::make('class')->options(array_column(User::$classes, 'text')),
|
||||
Forms\Components\Select::make('class')->options(User::listClass(User::CLASS_PEASANT, Auth::user()->class - 1)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,16 @@ class UserRepository extends BaseRepository
|
||||
if (mb_strlen($password) < 6 || mb_strlen($password) > 40) {
|
||||
throw new \InvalidArgumentException("Invalid password: $password, it should be more than 6 character and less than 40 character");
|
||||
}
|
||||
$class = !empty($params['class']) ? intval($params['class']) : User::CLASS_USER;
|
||||
if (!empty($params['class'])) {
|
||||
$class =intval($params['class']);
|
||||
$authUser = Auth::user();
|
||||
if ($authUser && $class >= $authUser->class) {
|
||||
throw new InsufficientPermissionException('No permission');
|
||||
}
|
||||
} else {
|
||||
$class = User::CLASS_USER;
|
||||
}
|
||||
|
||||
if (!isset(User::$classes[$class])) {
|
||||
throw new \InvalidArgumentException("Invalid user class: $class");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user