]> BookStack Code Mirror - bookstack/blobdiff - app/Entities/Tools/SearchRunner.php
Extend /users API endpoint
[bookstack] / app / Entities / Tools / SearchRunner.php
index 99634184a0f3421aa80512e3aa4aa66ed116a398..fc127f9068a49075d8cd14c2ad0e87968f96dd5b 100644 (file)
@@ -289,13 +289,11 @@ class SearchRunner
 
     protected function filterOwnedBy(EloquentBuilder $query, Entity $model, $input)
     {
-        if (!is_numeric($input) && $input !== 'me') {
-            return;
-        }
-        if ($input === 'me') {
-            $input = user()->id;
+        $userSlug = $input === 'me' ? user()->slug : trim($input);
+        $user = User::query()->where('slug', '=', $userSlug)->first(['id']);
+        if ($user) {
+            $query->where('owned_by', '=', $user->id);
         }
-        $query->where('owned_by', '=', $input);
     }
 
     protected function filterInName(EloquentBuilder $query, Entity $model, $input)