Skip to content

Commit 304d947

Browse files
committed
Allow creating subuser with no permissions
1 parent 96699b1 commit 304d947

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
1717
### Changed
1818
* Attempting to upload a folder via the web file manager will now display a warning telling the user to use SFTP.
1919
* Changing your account password will now log out all other sessions that currently exist for that user.
20+
* Subusers with no permissions selected can be created.
2021

2122
## v0.7.7 (Derelict Dermodactylus)
2223
### Fixed

app/Http/Controllers/Server/SubuserController.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ public function create(Request $request): View
157157
* @return \Illuminate\Http\RedirectResponse
158158
*
159159
* @throws \Exception
160-
* @throws \Illuminate\Auth\Access\AuthorizationException
161160
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
162161
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
163162
* @throws \Pterodactyl\Exceptions\Service\Subuser\ServerSubuserExistsException
@@ -171,7 +170,7 @@ public function store(SubuserStoreFormRequest $request): RedirectResponse
171170
$this->alert->success(trans('server.users.user_assigned'))->flash();
172171

173172
return redirect()->route('server.subusers.view', [
174-
'uuid' => $server->uuid,
173+
'uuid' => $server->uuidShort,
175174
'id' => $subuser->hashid,
176175
]);
177176
}

app/Http/Requests/Server/Subuser/SubuserStoreFormRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function rules()
2525
{
2626
return [
2727
'email' => 'required|email',
28-
'permissions' => 'present|array',
28+
'permissions' => 'sometimes|array',
2929
];
3030
}
3131
}

app/Services/Subusers/PermissionCreationService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public function handle($subuser, array $permissions)
5656
}
5757
}
5858

59-
$this->repository->withoutFreshModel()->insert($insertPermissions);
59+
if (! empty($insertPermissions)) {
60+
$this->repository->withoutFreshModel()->insert($insertPermissions);
61+
}
6062
}
6163
}

tests/Unit/Http/Controllers/Server/SubuserControllerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function testStoreController()
182182
$response = $controller->store($this->request);
183183
$this->assertIsRedirectResponse($response);
184184
$this->assertRedirectRouteEquals('server.subusers.view', $response, [
185-
'uuid' => $server->uuid,
185+
'uuid' => $server->uuidShort,
186186
'id' => $subuser->hashid,
187187
]);
188188
}

0 commit comments

Comments
 (0)