Skip to content

Commit 0afa568

Browse files
committed
Address two bugs in subuser system.
1.) Prevents adding the owner of a server as a subuser which could potentially break things. 2.) Prevents adding duplicate subusers for a server.
1 parent ef8e0b5 commit 0afa568

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
88
* Fixes bug where assigning a variable a default value (or valid value) of `0` would cause the panel to reject the value thinking it did not exist.
99
* Addresses potential for crash by limiting total ports that can be assigned per-range to 2000.
1010
* Fixes server names requiring at minimum 4 characters. Name can now be 1 to 200 characters long. :pencil2:
11+
* Fixes bug that would allow adding the owner of a server as a subuser for that same server.
12+
* Fixes bug that would allow creating multiple subusers with the same email address.
1113

1214
## v0.5.5 (Bodacious Boreopterus)
1315
### Added

app/Repositories/SubuserRepository.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function __construct()
117117
public function create($sid, array $data)
118118
{
119119
$server = Models\Server::findOrFail($sid);
120+
120121
$validator = Validator::make($data, [
121122
'permissions' => 'required|array',
122123
'email' => 'required|email',
@@ -140,6 +141,10 @@ public function create($sid, array $data)
140141
} catch (\Exception $ex) {
141142
throw $ex;
142143
}
144+
} else if ($server->owner === $user->id) {
145+
throw new DisplayException('You cannot add the owner of a server as a subuser.');
146+
} else if (Models\Subuser::select('id')->where('user_id', $user->id)->where('server_id', $server->id)->first()) {
147+
throw new DisplayException('A subuser with that email already exists for this server.');
143148
}
144149

145150
$uuid = new UuidService;
@@ -159,6 +164,7 @@ public function create($sid, array $data)
159164
if (! is_null($this->permissions[$permission])) {
160165
array_push($daemonPermissions, $this->permissions[$permission]);
161166
}
167+
162168
$model = new Models\Permission;
163169
$model->fill([
164170
'user_id' => $user->id,

0 commit comments

Comments
 (0)