flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 3b51a8b227148b98f16b949cbc3265df1b889936
parent b18acf6e7fa430cf39e4c02e45bb1e4463c65b23
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun,  6 Dec 2020 11:00:09 -0800

Add validate on delete

Diffstat:
Mhttp.go | 18++++++++++++------
Mtemplates/me.html | 1+
2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/http.go b/http.go @@ -553,13 +553,19 @@ func userFile(w http.ResponseWriter, r *http.Request) { func deleteAccountHandler(w http.ResponseWriter, r *http.Request) { user := newGetAuthUser(r) if r.Method == "POST" { - err := deleteUser(user.Username) - if err != nil { - log.Println(err) - renderDefaultError(w, http.StatusInternalServerError) - return + r.ParseForm() + validate := r.Form.Get("validate-delete") + if validate == user.Username { + err := deleteUser(user.Username) + if err != nil { + log.Println(err) + renderDefaultError(w, http.StatusInternalServerError) + return + } + logoutHandler(w, r) + } else { + http.Redirect(w, r, "/me", http.StatusSeeOther) } - logoutHandler(w, r) } } diff --git a/templates/me.html b/templates/me.html @@ -28,6 +28,7 @@ /> </div> </form> +<br> <a href="/reset-password">Reset password</a> <p><a href="/my_site/flounder-archive.zip">🗄️ Download my site archive (.zip)</a></p> <details>