From 308d3e796c33808d3a6ad33ff96af75e217960d1 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 8 Feb 2016 22:20:04 +0100 Subject: [PATCH] Add optional e-mail field to sign up form. --- main.go | 7 ++++--- templates/signupform.html | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index f46c6c2..ded9712 100644 --- a/main.go +++ b/main.go @@ -72,6 +72,7 @@ func signUpHandler(w http.ResponseWriter, r *http.Request) { name := r.FormValue("name") pw := r.FormValue("password") pw2 := r.FormValue("password2") + mail := r.FormValue("mail") if 0 != strings.Compare(pw, pw2) || 0 == strings.Compare("name", "") || 0 == strings.Compare(pw, "") || !onlyLegalRunes(name) || len(name) > 140 { @@ -99,7 +100,7 @@ func signUpHandler(w http.ResponseWriter, r *http.Request) { if err != nil { log.Fatal("Can't generate password hash", err) } - new_line := name + " " + string(hash) + "\n" + new_line := name + " " + string(hash) + " " + mail + "\n" appendToFile(loginsFile, new_line) execTemplate(w, "signup.html", "") } @@ -118,7 +119,7 @@ func listHandler(w http.ResponseWriter, r *http.Request) { } line := scanner.Text() tokens := strings.Split(line, " ") - if len(tokens) == 2 { + if len(tokens) == 3 { dir = append(dir, tokens[0]) } } @@ -145,7 +146,7 @@ func twtxtPostHandler(w http.ResponseWriter, r *http.Request) { } line := scanner.Text() tokens := strings.Split(line, " ") - if len(tokens) == 2 { + if len(tokens) == 3 { if 0 == strings.Compare(tokens[0], name) && nil == bcrypt.CompareHashAndPassword( []byte(tokens[1]), []byte(pw)) { diff --git a/templates/signupform.html b/templates/signupform.html index b73df9e..bf5498b 100644 --- a/templates/signupform.html +++ b/templates/signupform.html @@ -4,6 +4,7 @@ Name: (only up to 140 legal chars: A-Z, a-z, 0-1, _)
Password:
Password (repeat):
+ E-Mail: (optional; stored internally to reach and/or identify you when there's trouble with your feed, you want to reset your password, etc.; in any such communication, communicating from an address provided here is a necessary condition for you to be treated as the owner of your feed)