Remove test form
Signed-off-by: Odyssey346 <odyssey346@disroot.org>
This commit is contained in:
parent
2944f407ee
commit
d24c5eecee
16
api/form.go
16
api/form.go
@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"html/template"
|
||||
"log"
|
||||
|
||||
"github.com/kataras/hcaptcha"
|
||||
@ -21,13 +20,10 @@ var (
|
||||
secretKey = os.Getenv("HCAPTCHA_SECRET_KEY")
|
||||
webhookURL = os.Getenv("SEGFAUTILITIES_WEBHOOK_URL")
|
||||
client = hcaptcha.New(secretKey) /* See `Client.FailureHandler` too. */
|
||||
testForm = template.Must(template.ParseFiles("./static/testform.html"))
|
||||
)
|
||||
|
||||
func Form() {
|
||||
http.HandleFunc("/api/form", client.HandlerFunc(theActualFormCode))
|
||||
|
||||
http.HandleFunc("/form", renderTestForm)
|
||||
}
|
||||
|
||||
func theActualFormCode(w http.ResponseWriter, r *http.Request) {
|
||||
@ -63,15 +59,3 @@ func theActualFormCode(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
log.Println("[HTTP] " + otherthings.GetUserIP(r) + " accessed /api/form with method " + r.Method)
|
||||
}
|
||||
|
||||
func renderTestForm(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/html; charset=utf-8")
|
||||
testForm.Execute(w, map[string]string{
|
||||
"SiteKey": siteKey,
|
||||
})
|
||||
}
|
||||
|
||||
// testForm is only used in development. I will remove it when I've added it to the website
|
||||
// Oh also, you need to add the following to your hosts file:
|
||||
// 127.0.0.1 epicwebsite.com
|
||||
// and visit epicwebsite.com:(yourport)/form. hCaptcha doesn't work in localhost unfortunately :(
|
||||
|
@ -1,28 +0,0 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>hCaptcha Demo</title>
|
||||
<script src="https://hcaptcha.com/1/api.js" async defer></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form action="/api/form" method="POST">
|
||||
<input type="text" name="email" placeholder="Email" />
|
||||
<select id="commentType" name="commentType" required="required">
|
||||
<option value="" selected="selected" disabled="disabled">Select a type of comment</option>
|
||||
<option value="Feedback">Feedback</option>
|
||||
<option value="Suggestion">Suggestion</option>
|
||||
<option value="Question">Question</option>
|
||||
<option value="Bug">Bug</option>
|
||||
</select>
|
||||
<br />
|
||||
<textarea id="comment" name="message" rows="4" cols="50">
|
||||
Your message.
|
||||
</textarea>
|
||||
<div class="h-captcha" data-sitekey="{{ .SiteKey }}"></div>
|
||||
<br />
|
||||
<input type="submit" value="Submit" />
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user