commenter_new.go: do not return error on empty website

Closes https://gitlab.com/commento/commento-ce/issues/57
This commit is contained in:
JBP 2018-08-09 11:09:42 +02:00
parent eaa8001e7e
commit 99177a59c3

View File

@ -1,9 +1,10 @@
package main package main
import ( import (
"golang.org/x/crypto/bcrypt"
"net/http" "net/http"
"time" "time"
"golang.org/x/crypto/bcrypt"
) )
func commenterNew(email string, name string, link string, photo string, provider string, password string) (string, error) { func commenterNew(email string, name string, link string, photo string, provider string, password string) (string, error) {
@ -18,7 +19,7 @@ func commenterNew(email string, name string, link string, photo string, provider
// See utils_sanitise.go's documentation on isHttpsUrl. This is not a URL // See utils_sanitise.go's documentation on isHttpsUrl. This is not a URL
// validator, just an XSS preventor. // validator, just an XSS preventor.
// TODO: reject URLs instead of malforming them. // TODO: reject URLs instead of malforming them.
if !isHttpsUrl(link) { if link != "undefined" && !isHttpsUrl(link) {
link = "https://" + link link = "https://" + link
} }
@ -71,6 +72,10 @@ func commenterNewHandler(w http.ResponseWriter, r *http.Request) {
// TODO: add gravatar? // TODO: add gravatar?
// TODO: email confirmation if provider = commento? // TODO: email confirmation if provider = commento?
// TODO: email confirmation if provider = commento? // TODO: email confirmation if provider = commento?
if *x.Website == "" {
*x.Website = "undefined"
}
if _, err := commenterNew(*x.Email, *x.Name, *x.Website, "undefined", "commento", *x.Password); err != nil { if _, err := commenterNew(*x.Email, *x.Name, *x.Website, "undefined", "commento", *x.Password); err != nil {
bodyMarshal(w, response{"success": false, "message": err.Error()}) bodyMarshal(w, response{"success": false, "message": err.Error()})
return return