X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/44330bdd24a7dca1c85ab2068d335f089d4cff6d..refs/pull/2023/head:/app/Auth/Access/UserTokenService.php diff --git a/app/Auth/Access/UserTokenService.php b/app/Auth/Access/UserTokenService.php index 40f363ee1..a1defbf62 100644 --- a/app/Auth/Access/UserTokenService.php +++ b/app/Auth/Access/UserTokenService.php @@ -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 +}