all repos — flounder @ 3b51a8b227148b98f16b949cbc3265df1b889936

A small site builder for the Gemini protocol

Add validate on delete
alex wennerberg alex@alexwennerberg.com
Sun, 06 Dec 2020 11:00:09 -0800
commit

3b51a8b227148b98f16b949cbc3265df1b889936

parent

b18acf6e7fa430cf39e4c02e45bb1e4463c65b23

2 files changed, 13 insertions(+), 6 deletions(-)

jump to
M http.gohttp.go

@@ -553,13 +553,19 @@

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) } }
M templates/me.htmltemplates/me.html

@@ -28,6 +28,7 @@ value="Save"

/> </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>