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 25a2e2f commit 3c52a3b
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,36 +285,6 @@ private function generateAndSetCsrfToken(): string
return $csrfToken;
}


/**
* Generate a CSRF token.
*
* This method generates a CSRF token and stores it in a cookie.
* If a token already exists in the cookie, it is reused.
* @return string The generated or existing CSRF token.
*/
public function generateCsrfToken(): string
{
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'];
}

/**
* Get the CSRF token.
*
* This method retrieves the CSRF token from the cookie, or generates a new one if not available.
* @return string The CSRF token.
*/
public function getCsrfToken(): string
{
return $this->generateCsrfToken();
}

/**
* Check if the provided CSRF token matches the one in the session.
*
Expand Down

0 comments on commit 3c52a3b

Please sign in to comment.