fix create user

This commit is contained in:
xiaomlove
2023-08-22 02:02:55 +08:00
parent 21c4ca0bef
commit a64fee6422
3 changed files with 13 additions and 4 deletions
+10 -1
View File
@@ -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");
}