Skip to content

Commit

Permalink
update file
Browse files Browse the repository at this point in the history
  • Loading branch information
juancristobalgd1 authored Jan 4, 2024
1 parent a46d88e commit 65a06e5
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ public function getLocale()
/**
* Generate security tokens, including CSRF tokens.
*/
private function generateTokens(): void
private function generateTokens(): string
{
$this->generateCsrfToken();
return bin2hex(random_bytes(64) . time());
}

/**
Expand All @@ -265,9 +265,10 @@ private function generateTokens(): void
*/
public function generateCsrfToken(): string
{
if (!isset($_COOKIE['csrfToken'])) {
$csrfToken = bin2hex(random_bytes(64) . time());
if (empty($_COOKIE['csrfToken'])) {
$csrfToken = $this->generateTokens();
setcookie('csrfToken', $csrfToken, time() + 60 * config('session.expiration')); // Set the cookie to expire in 24 hours
return $csrfToken;
}

return $_COOKIE['csrfToken'];
Expand Down

0 comments on commit 65a06e5

Please sign in to comment.