]> BookStack Code Mirror - bookstack/blobdiff - app/Auth/Access/UserTokenService.php
Move logFailedAccess into Activity
[bookstack] / app / Auth / Access / UserTokenService.php
index 40f363ee13a788fa271b4ddbbe379b3a529f452b..a1defbf62d439a4bdacdef971271db1dde532afd 100644 (file)
@@ -5,6 +5,7 @@ use BookStack\Exceptions\UserTokenExpiredException;
 use BookStack\Exceptions\UserTokenNotFoundException;
 use Carbon\Carbon;
 use Illuminate\Database\Connection as Database;
+use Illuminate\Support\Str;
 use stdClass;
 
 class UserTokenService
@@ -61,7 +62,7 @@ class UserTokenService
         }
 
         if ($this->entryExpired($entry)) {
-            throw new UserTokenExpiredException("Token of id {$token->id} has expired.", $entry->user_id);
+            throw new UserTokenExpiredException("Token of id {$entry->id} has expired.", $entry->user_id);
         }
 
         return $entry->user_id;
@@ -73,9 +74,9 @@ class UserTokenService
      */
     protected function generateToken() : string
     {
-        $token = str_random(24);
+        $token = Str::random(24);
         while ($this->tokenExists($token)) {
-            $token = str_random(25);
+            $token = Str::random(25);
         }
         return $token;
     }
@@ -130,5 +131,4 @@ class UserTokenService
         return Carbon::now()->subHours($this->expiryTime)
             ->gt(new Carbon($tokenEntry->created_at));
     }
-
-}
\ No newline at end of file
+}