Browse Source

minor improvements

master
Christian Müller 8 years ago
parent
commit
fa158f485a
  1. 2
      assets/templates/form.html
  2. 2
      email.go
  3. 1
      server.go

2
assets/templates/form.html

@ -20,7 +20,7 @@
Accept <a href="/TOS.md">Terms of Service</a> Accept <a href="/TOS.md">Terms of Service</a>
</label> </label>
<div id="captcha" class="g-recaptcha" data-sitekey="6LemnDEUAAAAAC6A4VNRefz0BSLiC343W4sXQd6I"></div> <div id="captcha" class="g-recaptcha" data-sitekey="6LemnDEUAAAAAC6A4VNRefz0BSLiC343W4sXQd6I"></div>
<input class="button ui-elem" disabled id="publish-button" name="button" type="submit" value="Publish" /> <input class="button ui-elem" disabled id="publish-button" name="button" type="submit" value="Publish Note" />
</fieldset> </fieldset>
</form> </form>
<footer> <footer>

2
email.go

@ -10,7 +10,7 @@ func email(id, text string) error {
smtpServer := os.Getenv("SMTP_SERVER") smtpServer := os.Getenv("SMTP_SERVER")
auth := smtp.PlainAuth("", os.Getenv("SMTP_USER"), os.Getenv("SMTP_PASSWORD"), smtpServer) auth := smtp.PlainAuth("", os.Getenv("SMTP_USER"), os.Getenv("SMTP_PASSWORD"), smtpServer)
to := []string{os.Getenv("NOTEHUB_ADMIN_EMAIL")} to := []string{os.Getenv("NOTEHUB_ADMIN_EMAIL")}
msg := []byte("Subject: note reported\r\n\r\n" + msg := []byte("Subject: Note reported\r\n\r\n" +
fmt.Sprintf("Note https://notehub.org/%s was reported: %q\r\n", id, text)) fmt.Sprintf("Note https://notehub.org/%s was reported: %q\r\n", id, text))
return smtp.SendMail(smtpServer+":587", auth, to[0], to, msg) return smtp.SendMail(smtpServer+":587", auth, to[0], to, msg)
} }

1
server.go

@ -107,7 +107,6 @@ func main() {
e.POST("/note", func(c echo.Context) error { e.POST("/note", func(c echo.Context) error {
c.Logger().Debug("POST /note requested") c.Logger().Debug("POST /note requested")
if !skipCaptcha && !checkRecaptcha(c, c.FormValue("g-recaptcha-response")) { if !skipCaptcha && !checkRecaptcha(c, c.FormValue("g-recaptcha-response")) {
c.Logger().Warnf("captcha validation failed for %s", c.Request().RemoteAddr)
code := http.StatusForbidden code := http.StatusForbidden
return c.Render(code, "Note", responsePage(code)) return c.Render(code, "Note", responsePage(code))
} }

Loading…
Cancel
Save