Disallow non-super users from editing their own permissions

This commit is contained in:
snipe 2020-07-13 21:16:45 -07:00
parent 12c92e30b7
commit 5320f5c67c
No known key found for this signature in database
GPG key ID: 10BFFDA3ED34B5AC

View file

@ -240,6 +240,12 @@ class UsersController extends Controller
if ($user->id == $request->input('manager_id')) {
return redirect()->back()->withInput()->with('error', 'You cannot be your own manager.');
}
// If the user isn't a superuser, don't let them edit their own permissions
if ((!Auth::user()->isSuperUser()) && ($user->id == Auth::user()->id)) {
return redirect()->back()->withInput()->with('error', 'You cannot edit your own permissions. Please contact an administrator.');
}
$this->authorize('update', $user);
// Figure out of this user was an admin before this edit
$orig_permissions_array = $user->decodePermissions();