WIP on welcome tool

trunk
vilmibm 2023-02-26 08:57:46 +00:00
parent e339fa8cb6
commit 33ea591651
4 changed files with 103 additions and 4 deletions

View File

@ -7,8 +7,7 @@ responsible for:
2. accepting and validating a new user's username choice (ie enforcing rules and checking for dupes)
3. accepting and validating a user's email for use in account recovery (defaulting to an email embedded in the invite token)
4. accepting and validating a display name
5. asking what shell they'd like
6. accepting and validating a user's public ssh key
5. accepting and validating a user's public ssh key
upon receipt of these things a user account is created. if it fails, the user
is told about the failure and told to email root@tilde.town for guidance; us

View File

@ -1,7 +1,86 @@
package main
import "fmt"
import (
"fmt"
"os"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
_ "embed"
)
//go:embed welcome.txt
var welcomeArt string
// TODO remove ConnectDB abstraction in favor of just connecting directly to sqliteh
// TODO move magic key machine to static page
type newUserData struct {
Username string
DisplayName string
Email string
PubKey string
}
func _main() error {
app := tview.NewApplication()
//data := &newUserData{}
help := tview.NewTextView()
help.SetText("tab+enter or mouse to submit. ctrl+c to quit.")
help.SetTextColor(tcell.ColorGray)
artView := tview.NewTextView()
artView.SetText(welcomeArt)
artView.SetDynamicColors(true)
artView.SetBackgroundColor(tcell.ColorBlack)
artView.SetTextColor(tcell.ColorPurple)
// TODO colors wacky
tokenInput := tview.NewInputField()
tokenInput.SetLabel("invite code:")
tokenInput.SetFieldWidth(40)
tokenForm := tview.NewForm()
tokenForm.SetButtonBackgroundColor(tcell.ColorPurple)
tokenForm.SetButtonTextColor(tcell.ColorBlack)
tokenForm.SetButtonActivatedStyle(tcell.StyleDefault.Foreground(tcell.ColorWhite).Background(tcell.ColorPurple))
tokenForm.SetLabelColor(tcell.ColorPurple)
tokenForm.SetFieldBackgroundColor(tcell.ColorPurple)
tokenForm.AddFormItem(tokenInput)
tokenForm.AddButton("submit", func() {
app.Stop()
// TODO
})
tokenPage := tview.NewFlex()
tokenPage.SetDirection(tview.FlexRow)
tokenPage.AddItem(artView, 17, -1, false)
tokenPage.AddItem(tokenForm, 5, -1, true)
tokenPage.AddItem(help, 1, -1, false)
pages := tview.NewPages()
pages.AddPage("start", tokenPage, true, true)
app.SetRoot(pages, true)
/*
TODO multi-page flow:
- page 1: accept invite token
- page 2: username, display name, email
- page 3: public key
- page 4: next steps
*/
return app.EnableMouse(true).Run()
}
func main() {
fmt.Println("welcome")
err := _main()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}

View File

@ -0,0 +1,19 @@
_ ( ) . '
| | .
_ | | __ __ _ _ _ _ _|_ __ __ :
| | |_|/ |/ / / \_/ |/ |/ | |/ | / \_ / /\ __ ___!__ _,__ ___,_
\/ \/ |__/|__/\___/\__/ | | |_/|__/ |_/\__/ / / o\/ \ / /\ /__/ \ /__\__\
/ \\ \/_____ /_*\ | |[^][^| | |
_ / /\ | | |_|__| .: |__|__|
o | | | || | {^} | |
_|_ | | __| _ _|_ __ _ _ [] [] | | | |. . A ._ . .
| | |/ / | |/ | / \_| | |_/ |/ | _ _ |___|__|__D_| . H / \ {^}
|_/|_/|__/\_/|_/|__/o|_/\__/ \/ \/ | |_/ | |[@] | | . . . | |/ \ |
_|_|_____| . . |^| \ |
. . v v . | | \|.
. v v . / O \ /|
|_ u _| . . / _ \ / |
we're glad you're here || | || / |_| \/ |
| | |.

View File

@ -1,5 +1,7 @@
package signup
// TODO delete this file
import (
"database/sql"