harish81 / digidocu

Open Source Documents Management System Built with Laravel 6
https://nandoliyaharish.gitbook.io/digidocu/
GNU General Public License v3.0
107 stars 64 forks source link

Document viewing produces PHP error if "Permissions management User" is not enabled for the User #9

Closed CrowCakes closed 2 years ago

CrowCakes commented 3 years ago

Version: 1.0.1

When attempting to view a Document as a regular user with valid read permissions, a PHP error occurs with a callback to /app/Http/Controllers/DocumentController.php, in a function called view().

if (auth()->user()->can('user manage permission')) { $users = User::where('id', '!=', 1)->get(); $thisDocPermissionUsers = $this->permissionRepository->getUsersWiseDocumentLevelPermissionsForDoc($document); //Tag Level permission $tagWisePermList = $this->permissionRepository->getTagWiseUsersPermissionsForDoc($document); //Global Permission $globalPermissionUsers = $this->permissionRepository->getGlobalPermissionsForDoc($document); } return view('documents.show', compact('document', 'missigDocMsgs', 'users', 'thisDocPermissionUsers', 'tagWisePermList', 'globalPermissionUsers'));

Since the code snippet included the permissions management for Documents, I enabled it for the User. The Document could then be viewed by their account without problems. However, since the permissions management is toggleable, it should either be on by default to prevent the error from appearing, or the view should not render the permissions tab at all if permission management is not allowed for the User.