Add optional e-mail field to sign up form.

このコミットが含まれているのは:
Christian Heller 2016-02-08 22:20:04 +01:00
コミット 308d3e796c
2個のファイルの変更5行の追加3行の削除

ファイルの表示

@ -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)) {

ファイルの表示

@ -4,6 +4,7 @@
Name: <input type="text" name="name" /> (only up to 140 legal chars: A-Z, a-z, 0-1, _)<br />
Password: <input type="password" name="password" /><br />
Password (repeat): <input type="password" name="password2" /><br />
E-Mail: <input type="text" name="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)<br />
<input type="submit" value="create" />
</form>
<hr />