create server with user ID or email
This commit is contained in:
parent
9d10c2a757
commit
fbfaec6b20
2 changed files with 11 additions and 3 deletions
|
@ -9,6 +9,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
|||
* Added support for file copying through the file manager. [#127](https://github.com/Pterodactyl/Panel/issues/127)
|
||||
* Added support for creating new files and folders directly from the right-click dropdown menu.
|
||||
* Added support for setting custom `user_id` when using the API to create users.
|
||||
* Support for creating a new server through the API by passing a user ID rather than an email.
|
||||
|
||||
### Changed
|
||||
* Support for sub-folders within the `getJavascript()` route for servers.
|
||||
|
|
|
@ -77,7 +77,7 @@ class ServerRepository
|
|||
|
||||
// Validate Fields
|
||||
$validator = Validator::make($data, [
|
||||
'owner' => 'bail|required|email|exists:users,email',
|
||||
'owner' => 'bail|required|string',
|
||||
'name' => 'required|regex:/^([\w -]{4,35})$/',
|
||||
'memory' => 'required|numeric|min:0',
|
||||
'swap' => 'required|numeric|min:-1',
|
||||
|
@ -114,8 +114,15 @@ class ServerRepository
|
|||
throw new DisplayValidationException($validator->errors());
|
||||
}
|
||||
|
||||
// Get the User ID; user exists since we passed the 'exists:users,email' part of the validation
|
||||
$user = Models\User::select('id')->where('email', $data['owner'])->first();
|
||||
if (is_int($data['owner'])) {
|
||||
$user = Models\User::select('id')->where('id', $data['owner'])->first();
|
||||
} else {
|
||||
$user = Models\User::select('id')->where('email', $data['owner'])->first();
|
||||
}
|
||||
|
||||
if (!$user) {
|
||||
throw new DisplayValidationException('The user id or email passed to the function was not found on the system.');
|
||||
}
|
||||
|
||||
$autoDeployed = false;
|
||||
if (isset($data['auto_deploy']) && in_array($data['auto_deploy'], [true, 1, "1"])) {
|
||||
|
|
Loading…
Reference in a new issue