]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/Permissions/PermissionsRepo.php
Move logFailedAccess into Activity
[bookstack] / app / Auth / Permissions / PermissionsRepo.php
index 98a8a9f14336ae48bd56171096b05d8761ea3ef1..56ef193015f7103a98bb440ec60498e5bf765c25 100644 (file)
@@ -1,11 +1,9 @@
 <?php namespace BookStack\Auth\Permissions;
 
 use BookStack\Auth\Permissions;
-use BookStack\Exceptions\PermissionsException;
-use BookStack\Auth\Permissions\RolePermission;
 use BookStack\Auth\Role;
-use BookStack\Auth\Permissions\PermissionService;
-use Setting;
+use BookStack\Exceptions\PermissionsException;
+use Illuminate\Support\Str;
 
 class PermissionsRepo
 {
@@ -69,7 +67,7 @@ class PermissionsRepo
         $role->name = str_replace(' ', '-', strtolower($roleData['display_name']));
         // Prevent duplicate names
         while ($this->role->where('name', '=', $role->name)->count() > 0) {
-            $role->name .= strtolower(str_random(2));
+            $role->name .= strtolower(Str::random(2));
         }
         $role->save();
 
@@ -139,7 +137,7 @@ class PermissionsRepo
         // Prevent deleting admin role or default registration role.
         if ($role->system_name && in_array($role->system_name, $this->systemRoles)) {
             throw new PermissionsException(trans('errors.role_system_cannot_be_deleted'));
-        } else if ($role->id == setting('registration-role')) {
+        } else if ($role->id === intval(setting('registration-role'))) {
             throw new PermissionsException(trans('errors.role_registration_default_cannot_delete'));
         }