email collection
parent
9442ecb55e
commit
add10cb754
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/mail"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
@ -80,6 +81,27 @@ func promptUsername(townData stats.TildeData) (un string, err error) {
|
|||
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 {
|
||||
townData, err := stats.Stats()
|
||||
if err != nil {
|
||||
|
@ -125,8 +147,11 @@ func _main() error {
|
|||
return err
|
||||
}
|
||||
|
||||
// TODO collect username
|
||||
// TODO collect email
|
||||
data.Email, err = promptEmail(invite.Email)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO collect public key
|
||||
// TODO have enough to make account; can now do that
|
||||
// TODO assuming account creation succeeded, mark invite as used
|
||||
|
|
Loading…
Reference in New Issue