diff --git a/src/Csrf/CsrfDataHandler.php b/src/Csrf/CsrfDataHandler.php index 070b9c9..358883e 100644 --- a/src/Csrf/CsrfDataHandler.php +++ b/src/Csrf/CsrfDataHandler.php @@ -16,7 +16,12 @@ public function __construct($formSecret, $sessionSecret) { $this->setFormSecret($formSecret); $this->setSessionSecret($sessionSecret); + } + + public function applyNewToken() + { $this->setValue(password_hash($this->_generatePassword(), PASSWORD_DEFAULT)); + return $this; } protected function _generatePassword() diff --git a/tests/Csrf/CsrfFormTest.php b/tests/Csrf/CsrfFormTest.php index 988f7da..877b2f4 100644 --- a/tests/Csrf/CsrfFormTest.php +++ b/tests/Csrf/CsrfFormTest.php @@ -10,6 +10,7 @@ public function testCsrfToken() { $secret = 'user-secret'; $form = new CsrfForm($secret); + $form->csrfToken->applyNewToken(); $formValue = $form->csrfToken->getValue(); $this->assertTrue($form->csrfToken->isValid()); @@ -30,6 +31,7 @@ public function testRender() { $secret = 'user-secret'; $form = new CsrfForm($secret); + $form->csrfToken->applyNewToken(); $html = $form->produceSafeHTML()->getContent(); $this->assertRegExp( '/\