]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Controllers/Controller.php
Replace dots with something else on user create and edit screens
[bookstack] / app / Http / Controllers / Controller.php
index 80f567eaa80279e8f49599f9703f5ab29e6276c3..fc4f184fcabdff0bf292b6f6c257912ce6d98a2d 100644 (file)
@@ -123,6 +123,20 @@ abstract class Controller extends BaseController
         return true;
     }
 
+    /**
+     * Check if the current user has a permission or bypass if the provided user
+     * id matches the current user.
+     * @param string $permissionName
+     * @param int $userId
+     * @return bool
+     */
+    protected function checkPermissionOrCurrentUser(string $permissionName, int $userId)
+    {
+        return $this->checkPermissionOr($permissionName, function() use ($userId) {
+            return $userId === $this->currentUser->id;
+        });
+    }
+
     /**
      * Send back a json error message.
      * @param string $messageText