Added a remove URL query parameter for IsSolved() handler. Calls a Remove() method of a DB.

This commit is contained in:
Alexander Andreev 2022-08-28 23:32:16 +04:00
parent ae67f6aa4f
commit 0b064e8977
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

View File

@ -60,6 +60,15 @@ func (h *CaptchaHandlers) Solve(w http.ResponseWriter, r *http.Request) {
func (h *CaptchaHandlers) IsSolved(w http.ResponseWriter, r *http.Request) { func (h *CaptchaHandlers) IsSolved(w http.ResponseWriter, r *http.Request) {
captchaID := pcaptcha.ID(server.GetURLParam(r, "captcha")) captchaID := pcaptcha.ID(server.GetURLParam(r, "captcha"))
isJustRemove := r.URL.Query().Has("remove")
if isJustRemove {
err := captcha.Remove(captchaID)
if err != nil {
w.WriteHeader(http.StatusNotFound)
}
return
}
solved, err := captcha.IsSolved(captchaID) solved, err := captcha.IsSolved(captchaID)
if err != nil { if err != nil {