diff --git a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php index 7c4fab9d22..c6ec44b11b 100644 --- a/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php +++ b/app/Http/Requests/Api/Client/Servers/Subusers/SubuserRequest.php @@ -24,10 +24,20 @@ public function authorize(): bool return false; } + // Always authorize requests from a root admin. + if ($this->user()->root_admin) { + return true; + } + $user = $this->route()->parameter('user'); // Don't allow a user to edit themselves on the server. if ($user instanceof User) { if ($user->uuid === $this->user()->uuid) { + // Except if they want to delete themselves from the server. + if ($this->method() === Request::METHOD_DELETE) { + return true; + } + return false; } } diff --git a/resources/scripts/components/server/users/UserRow.tsx b/resources/scripts/components/server/users/UserRow.tsx index 45693c5d49..df181df5e1 100644 --- a/resources/scripts/components/server/users/UserRow.tsx +++ b/resources/scripts/components/server/users/UserRow.tsx @@ -15,6 +15,7 @@ interface Props { export default ({ subuser }: Props) => { const uuid = useStoreState((state) => state.user!.data!.uuid); + const rootAdmin = useStoreState((state) => state.user!.data!.rootAdmin); const [visible, setVisible] = useState(false); return ( @@ -44,7 +45,7 @@ export default ({ subuser }: Props) => {
Permissions
- {subuser.uuid !== uuid && ( + {(subuser.uuid !== uuid || rootAdmin) && ( <>