diff --git a/csrf.php b/csrf.php index 89cb653..d9e7cf3 100644 --- a/csrf.php +++ b/csrf.php @@ -164,4 +164,16 @@ class csrf return true; } // }}} + + /** Check an existing token, then delete it + * @param string $tokenFromUser The existing token + */ + public function checkThenDeleteToken ($tokenFromUser) + // {{{ + { + $this->checkToken ($tokenFromUser); + unset ($_SESSION["domframework"]["csrf"][$tokenFromUser]); + return true; + } + // }}} } diff --git a/form.php b/form.php index b61f18f..ba6d0b4 100644 --- a/form.php +++ b/form.php @@ -416,7 +416,9 @@ class form { $csrf = new csrf (); $csrf->field = $this->csrfField; - $csrf->checkToken ($tokenFromUser); + // The checkThenDeleteToken method check the token and except if there is a + // problem. If there is no problem, it delete the token + $csrf->checkThenDeleteToken ($tokenFromUser); } // }}}