]> BookStack Code Mirror - bookstack/blobdiff - app/Api/ApiTokenGuard.php
Add base64 image support
[bookstack] / app / Api / ApiTokenGuard.php
index ba0b4b5dd5160581a3e1b975445c643c60c5c46b..59ab72f4eb8509be037704fdddff907bda4403b4 100644 (file)
@@ -6,6 +6,7 @@ use BookStack\Exceptions\ApiAuthException;
 use Illuminate\Auth\GuardHelpers;
 use Illuminate\Contracts\Auth\Authenticatable;
 use Illuminate\Contracts\Auth\Guard;
+use Illuminate\Support\Carbon;
 use Illuminate\Support\Facades\Hash;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -125,6 +126,11 @@ class ApiTokenGuard implements Guard
             throw new ApiAuthException(trans('errors.api_incorrect_token_secret'));
         }
 
+        $now = Carbon::now();
+        if ($token->expires_at <= $now) {
+            throw new ApiAuthException(trans('errors.api_user_token_expired'), 403);
+        }
+
         if (!$token->user->can('access-api')) {
             throw new ApiAuthException(trans('errors.api_user_no_api_permission'), 403);
         }
@@ -157,4 +163,4 @@ class ApiTokenGuard implements Guard
     {
         $this->user = null;
     }
-}
\ No newline at end of file
+}