]> BookStack Code Mirror - bookstack/blobdiff - app/Http/Middleware/ApiAuthenticate.php
Move logFailedAccess into Activity
[bookstack] / app / Http / Middleware / ApiAuthenticate.php
index 655334450f8d1cfac8a2efc148c337edcccf4cb3..15962b3b00471d1fc55dd2a229824b50319886d6 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace BookStack\Http\Middleware;
 
+use BookStack\Exceptions\ApiAuthException;
 use BookStack\Exceptions\UnauthorizedException;
 use Closure;
 use Illuminate\Http\Request;
@@ -36,6 +37,9 @@ class ApiAuthenticate
         // This is to make it easy to browser the API via browser after just logging into the system.
         if (signedInUser()) {
             $this->ensureEmailConfirmedIfRequested();
+            if (!auth()->user()->can('access-api')) {
+                throw new ApiAuthException(trans('errors.api_user_no_api_permission'), 403);
+            }
             return;
         }