diff options
| author | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-31 11:47:54 -0600 |
|---|---|---|
| committer | Elizabeth Hunt <elizabeth.hunt@simponic.xyz> | 2024-03-31 11:47:54 -0600 |
| commit | 2c6b124664607e88ba1b992e22a7041dd2f2b807 (patch) | |
| tree | ac468938e717051fe5d2930b606d6269c9f883bb /api/guestbook.go | |
| parent | 5080c566ac31ec622986c04f1812a1e88c88210e (diff) | |
| download | hatecomputers.club-2c6b124664607e88ba1b992e22a7041dd2f2b807.tar.gz hatecomputers.club-2c6b124664607e88ba1b992e22a7041dd2f2b807.zip | |
guestbook qol improvements
Diffstat (limited to 'api/guestbook.go')
| -rw-r--r-- | api/guestbook.go | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/api/guestbook.go b/api/guestbook.go index 2037e7e..7b84f45 100644 --- a/api/guestbook.go +++ b/api/guestbook.go @@ -27,8 +27,8 @@ func validateGuestbookEntry(entry *database.GuestbookEntry) []string { } messageLength := len(entry.Message) - if messageLength < 10 || messageLength > 500 { - errors = append(errors, "message must be between 10 and 500 characters") + if messageLength > 500 { + errors = append(errors, "message cannot be longer than 500 characters") } newLines := strings.Count(entry.Message, "\n") @@ -58,19 +58,17 @@ func SignGuestbookContinuation(context *RequestContext, req *http.Request, resp Name: name, Message: message, } - formErrors.Errors = append(formErrors.Errors, validateGuestbookEntry(entry)...) - if len(formErrors.Errors) > 0 { - (*context.TemplateData)["FormError"] = formErrors - return failure(context, req, resp) - } - err := verifyHCaptcha(context.Args.HcaptchaSecret, hCaptchaResponse) if err != nil { log.Println(err) - resp.WriteHeader(http.StatusBadRequest) + formErrors.Errors = append(formErrors.Errors, "hCaptcha verification failed") + } + if len(formErrors.Errors) > 0 { + (*context.TemplateData)["FormError"] = formErrors + (*context.TemplateData)["EntryForm"] = entry return failure(context, req, resp) } |
