mirror of
https://github.com/daledavies/jump.git
synced 2026-01-11 01:42:09 +01:00
Fix session locking issue after refactoring routing
This commit is contained in:
@@ -23,6 +23,9 @@ class Main {
|
||||
$this->router = new RouteList;
|
||||
|
||||
// Set up the routes that Jump expects.
|
||||
$this->router->addRoute('/', [
|
||||
'class' => 'Jump\Pages\HomePage'
|
||||
]);
|
||||
$this->router->addRoute('/tag/<tag>', [
|
||||
'class' => 'Jump\Pages\TagPage'
|
||||
]);
|
||||
@@ -46,14 +49,6 @@ class Main {
|
||||
$this->session->setName($this->config->get('sessionname'));
|
||||
$this->session->setExpiration($this->config->get('sessiontimeout'));
|
||||
|
||||
// Get a Nette session section for CSRF data.
|
||||
$csrfsection = $this->session->getSection('csrf');
|
||||
|
||||
// Create a new CSRF token within the section if one doesn't exist already.
|
||||
if (!$csrfsection->offsetExists('token')){
|
||||
$csrfsection->set('token', bin2hex(random_bytes(32)));
|
||||
}
|
||||
|
||||
// Try to match the correct route based on the HTTP request.
|
||||
$matchedroute = $this->router->match($this->request);
|
||||
|
||||
|
||||
@@ -28,6 +28,12 @@ abstract class AbstractPage {
|
||||
return urlencode($renderer($text));
|
||||
}),
|
||||
]);
|
||||
// Get a Nette session section for CSRF data.
|
||||
$csrfsection = $this->session->getSection('csrf');
|
||||
// Create a new CSRF token within the section if one doesn't exist already.
|
||||
if (!$csrfsection->offsetExists('token')){
|
||||
$csrfsection->set('token', bin2hex(random_bytes(32)));
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected function render_content(): string;
|
||||
|
||||
Reference in New Issue
Block a user