Merge branch 'develop' into feature/service-changes
This commit is contained in:
commit
6bd9663f59
136 changed files with 2470 additions and 1737 deletions
|
@ -213,7 +213,13 @@ class NodeRepository
|
|||
throw new DisplayException('The mapping for ' . $port . ' is invalid and cannot be processed.');
|
||||
}
|
||||
if (preg_match('/^(\d{1,5})-(\d{1,5})$/', $port, $matches)) {
|
||||
foreach (range($matches[1], $matches[2]) as $assignPort) {
|
||||
$portBlock = range($matches[1], $matches[2]);
|
||||
|
||||
if (count($portBlock) > 2000) {
|
||||
throw new DisplayException('Adding more than 2000 ports at once is not currently supported. Please consider using a smaller port range.');
|
||||
}
|
||||
|
||||
foreach ($portBlock as $assignPort) {
|
||||
$alloc = Models\Allocation::firstOrNew([
|
||||
'node' => $node->id,
|
||||
'ip' => $ip,
|
||||
|
@ -252,7 +258,6 @@ class NodeRepository
|
|||
}
|
||||
|
||||
DB::commit();
|
||||
// return true;
|
||||
} catch (\Exception $ex) {
|
||||
DB::rollBack();
|
||||
throw $ex;
|
||||
|
@ -277,6 +282,9 @@ class NodeRepository
|
|||
// Delete Allocations
|
||||
Models\Allocation::where('node', $node->id)->delete();
|
||||
|
||||
// Delete configure tokens
|
||||
Models\NodeConfigurationToken::where('node', $node->id)->delete();
|
||||
|
||||
// Delete Node
|
||||
$node->delete();
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ class ServerRepository
|
|||
// Validate Fields
|
||||
$validator = Validator::make($data, [
|
||||
'owner' => 'bail|required',
|
||||
'name' => 'required|regex:/^([\w -]{4,35})$/',
|
||||
'name' => 'required|regex:/^([\w .-]{1,200})$/',
|
||||
'memory' => 'required|numeric|min:0',
|
||||
'swap' => 'required|numeric|min:-1',
|
||||
'io' => 'required|numeric|min:10|max:1000',
|
||||
|
@ -179,7 +179,7 @@ class ServerRepository
|
|||
foreach ($variables as $variable) {
|
||||
|
||||
// Is the variable required?
|
||||
if (! $data['env_' . $variable->env_variable]) {
|
||||
if (! isset($data['env_' . $variable->env_variable])) {
|
||||
if ($variable->required === 1) {
|
||||
throw new DisplayException('A required service option variable field (env_' . $variable->env_variable . ') was missing from the request.');
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ class ServerRepository
|
|||
// Validate Fields
|
||||
$validator = Validator::make($data, [
|
||||
'owner' => 'email|exists:users,email',
|
||||
'name' => 'regex:([\w -]{4,35})',
|
||||
'name' => 'regex:([\w .-]{1,200})',
|
||||
]);
|
||||
|
||||
// Run validator, throw catchable and displayable exception if it fails.
|
||||
|
|
|
@ -117,6 +117,7 @@ class SubuserRepository
|
|||
public function create($sid, array $data)
|
||||
{
|
||||
$server = Models\Server::findOrFail($sid);
|
||||
|
||||
$validator = Validator::make($data, [
|
||||
'permissions' => 'required|array',
|
||||
'email' => 'required|email',
|
||||
|
@ -140,6 +141,10 @@ class SubuserRepository
|
|||
} catch (\Exception $ex) {
|
||||
throw $ex;
|
||||
}
|
||||
} elseif ($server->owner === $user->id) {
|
||||
throw new DisplayException('You cannot add the owner of a server as a subuser.');
|
||||
} elseif (Models\Subuser::select('id')->where('user_id', $user->id)->where('server_id', $server->id)->first()) {
|
||||
throw new DisplayException('A subuser with that email already exists for this server.');
|
||||
}
|
||||
|
||||
$uuid = new UuidService;
|
||||
|
@ -159,6 +164,7 @@ class SubuserRepository
|
|||
if (! is_null($this->permissions[$permission])) {
|
||||
array_push($daemonPermissions, $this->permissions[$permission]);
|
||||
}
|
||||
|
||||
$model = new Models\Permission;
|
||||
$model->fill([
|
||||
'user_id' => $user->id,
|
||||
|
|
Reference in a new issue