Przeglądaj źródła

修复知识库权限问题

kuaifan 5 lat temu
rodzic
commit
16df5af00c

+ 6 - 4
app/Http/Controllers/Api/DocsController.php

@@ -44,7 +44,7 @@ class DocsController extends Controller
         }
         //
         $lists = DB::table('docs_book')
-            ->where('role_edit', 'reg')
+            ->where('username', $user['username'])
             ->orWhere(function ($query) use ($user) {
                 $query->where('role_edit', 'private')->where('username', $user['username']);
             })
@@ -82,9 +82,11 @@ class DocsController extends Controller
         //
         $id = intval(Request::input('id'));
         $title = trim(Request::input('title'));
-        $role = Docs::checkRole($id, 'edit');
-        if (Base::isError($role)) {
-            return $role;
+        if ($id > 0) {
+            $role = Docs::checkRole($id, 'edit');
+            if (Base::isError($role)) {
+                return $role;
+            }
         }
         if (mb_strlen($title) < 2 || mb_strlen($title) > 100) {
             return Base::retError('标题限制2-100个字!');

+ 4 - 0
app/Module/Docs.php

@@ -43,6 +43,10 @@ class Docs
                 }
             }
         }
+        if ($user['username'] == $row['username']) {
+            return Base::retSuccess('success');
+        }
+        //
         if ($row['role_' . $checkType] == 'member') {
             if (!DB::table('docs_users')->where('bookid', $bookid)->where('username', $user['username'])->exists()) {
                 return Base::retError('知识库仅对成员开放!', -1002);