From 09269126d87c497146bd201b2b2d92b6c129a229 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Mon, 6 Mar 2023 21:00:59 +0000 Subject: [PATCH] CoC prompt --- cmd/welcome/form.go | 12 ++++++++++++ cmd/welcome/main.go | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/cmd/welcome/form.go b/cmd/welcome/form.go index b080748..aa821c9 100644 --- a/cmd/welcome/form.go +++ b/cmd/welcome/form.go @@ -29,6 +29,18 @@ func promptCode() (code string, err error) { return } +func confirmCoC() (conf bool, err error) { + err = survey.AskOne( + &survey.Confirm{ + Message: "do you agree to the above CoC?", + Default: true, + }, &conf, + survey.WithValidator(survey.Required), + survey.WithIcons(surveyIconSet)) + return + +} + func confirmContinue() (conf bool, err error) { err = survey.AskOne( &survey.Confirm{ diff --git a/cmd/welcome/main.go b/cmd/welcome/main.go index 5818ada..285f1a3 100644 --- a/cmd/welcome/main.go +++ b/cmd/welcome/main.go @@ -19,7 +19,6 @@ import ( // TODO add logging like the signup tool has // TODO consider merging adduser, usermod, and createkeyfile into single createuser helper to limit sudoers list // TODO move magic key machine to static page -// TODO link to code of conduct as part of the form and ask if they agree // TODO add alerts for new users (mailing list post, irc post, etc(?)) //go:embed welcome.txt @@ -102,7 +101,22 @@ func _main() error { } } - s = s.SetString("cool, awesome, going to make your account now...") + s = s.SetString("town users all agree to our code of conduct: https://tilde.town/wiki/conduct.html") + + fmt.Println(s) + + coc, err := confirmCoC() + if err != nil { + return err + } + + if !coc { + s = s.SetString("bummer. have a good one.") + fmt.Println(s) + return nil + } + + s = s.SetString("cool, awesome, thank you, going to make your account now...") fmt.Println(s) if err = createUser(*data); err != nil {