forked from tildetown/town
email collection
parent
9442ecb55e
commit
add10cb754
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/mail"
|
||||||
"os"
|
"os"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -80,6 +81,27 @@ func promptUsername(townData stats.TildeData) (un string, err error) {
|
||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func promptEmail(defaultEmail string) (email string, err error) {
|
||||||
|
emailPrompt := &survey.Input{
|
||||||
|
Message: "e-mail (for account recovery only)?",
|
||||||
|
Default: defaultEmail,
|
||||||
|
}
|
||||||
|
err = survey.AskOne(emailPrompt, &email,
|
||||||
|
survey.WithValidator(survey.Required),
|
||||||
|
survey.WithIcons(surveyIconSet),
|
||||||
|
survey.WithValidator(func(val interface{}) error {
|
||||||
|
email := val.(string)
|
||||||
|
_, err := mail.ParseAddress(email)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not understand that email: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}))
|
||||||
|
|
||||||
|
return "", nil
|
||||||
|
}
|
||||||
|
|
||||||
func _main() error {
|
func _main() error {
|
||||||
townData, err := stats.Stats()
|
townData, err := stats.Stats()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -125,8 +147,11 @@ func _main() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO collect username
|
data.Email, err = promptEmail(invite.Email)
|
||||||
// TODO collect email
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// TODO collect public key
|
// TODO collect public key
|
||||||
// TODO have enough to make account; can now do that
|
// TODO have enough to make account; can now do that
|
||||||
// TODO assuming account creation succeeded, mark invite as used
|
// TODO assuming account creation succeeded, mark invite as used
|
||||||
|
|
Loading…
Reference in New Issue