]> BookStack Code Mirror - bookstack/blobdiff - app/Repos/PermissionsRepo.php
#47 - Fixes the issues with the test case.
[bookstack] / app / Repos / PermissionsRepo.php
index 24497c91135fa036825bcb180e88df65ba099727..aa58d1718cc6bd22775c08d31fabd862159e4731 100644 (file)
@@ -93,7 +93,7 @@ class PermissionsRepo
         $permissions = isset($roleData['permissions']) ? array_keys($roleData['permissions']) : [];
         $this->assignRolePermissions($role, $permissions);
 
-        if ($role->name === 'admin') {
+        if ($role->system_name === 'admin') {
             $permissions = $this->permission->all()->pluck('id')->toArray();
             $role->permissions()->sync($permissions);
         }
@@ -133,9 +133,9 @@ class PermissionsRepo
 
         // Prevent deleting admin role or default registration role.
         if ($role->system_name && in_array($role->system_name, $this->systemRoles)) {
-            throw new PermissionsException('This role is a system role and cannot be deleted');
+            throw new PermissionsException(trans('errors.role_system_cannot_be_deleted'));
         } else if ($role->id == setting('registration-role')) {
-            throw new PermissionsException('This role cannot be deleted while set as the default registration role.');
+            throw new PermissionsException(trans('errors.role_registration_default_cannot_delete'));
         }
 
         if ($migrateRoleId) {