deform icon indicating copy to clipboard operation
deform copied to clipboard

Fix bug when CSRF token does not appear in a form

Open adisloom opened this issue 3 years ago • 2 comments

This fixes a bug when csrf_token value appears empty in a form in the case when a schema has been created before creating a session factory, i.e. ..input type="hidden" name="csrf_token" value="" id=.... Also, calling the function deferred_csrf_value() directly produced an error message "No session factory registered (see the Sessions chapter of the Pyramid documentation)". My fix calls the safe function get_csrf_token() which always returns a token, creates it if neccessary.

adisloom avatar Jun 11 '22 09:06 adisloom

The test fails because it uses DummyReqest. Real request works fine.

adisloom avatar Jun 11 '22 09:06 adisloom

@adisloom thank you for your pull request. However I cannot accept it because Deform does not require Pyramid, and this PR would make it a requirement. Pyramid is used only for running tests.

stevepiercy avatar Jun 11 '22 09:06 stevepiercy