komuw / ong

ong, is a Go http toolkit.
MIT License
16 stars 4 forks source link

reload protector should defer deletion of cookie. #447

Open komuw opened 1 month ago

komuw commented 1 month ago

https://github.com/komuw/ong/blob/07606656415a32bfc40c6f5e8737bd0187251b6b/middleware/reload_protect.go#L18-L28

        defer func() {
            cookie.Delete(
                w,
                theCookie,
                o.Domain,
            )
        }()

There's a bug where all second legitimate submissions of from fail

komuw commented 1 month ago

I don't think there's a bug. I had a html form like;

<form>
<button id="resetButton">Reset</button>
</form>

And everytime I would press the button it would submit an empty form, which I would presume to be a bug in ong. But what I needed is;

<button id="resetButton" type="button">Reset purchase</button>
<!-- Make sure the button has a type==button so that it doesn't submit which is the default action for butoons. -->
komuw commented 4 weeks ago

https://en.wikipedia.org/wiki/Post/Redirect/Get