Compare commits
No commits in common. "be5020ad28b6ef0811d2c318f1bdf66c3c90ac67" and "2a07a0e200aa84780e7d038bcfb1608a26ae5e33" have entirely different histories.
be5020ad28
...
2a07a0e200
|
@ -9,5 +9,3 @@ cmd/welcome/welcome
|
|||
cmd/createkeyfile/createkeyfile
|
||||
cmd/registeruser/registeruser
|
||||
cmd/stats/stats
|
||||
cmd/appendkeyfile/appendkeyfile
|
||||
cmd/help/help
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
// TODO accept an email as an argument, write out a username associated with it or throw an error
|
||||
|
||||
func main() {
|
||||
fmt.Println("TODO")
|
||||
}
|
|
@ -22,15 +22,6 @@ import (
|
|||
|
||||
// TODO put colorscheme, prompting stuff into own packages for use in the other commands. would be good to get off of survey.
|
||||
|
||||
func connectDB() (*sql.DB, error) {
|
||||
db, err := sql.Open("sqlite3", "/town/var/codes/codes.db?mode=rw")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
type colorScheme struct {
|
||||
Header func(string) string
|
||||
Subtitle func(string) string
|
||||
|
@ -117,7 +108,7 @@ func (p *Prompter) Select(prompt string, opts []string) (int, error) {
|
|||
}
|
||||
|
||||
func _main(cs colorScheme) error {
|
||||
db, err := connectDB()
|
||||
db, err := towndb.ConnectDB()
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not connect to database. please let root@tilde.town know about this.")
|
||||
}
|
||||
|
@ -158,12 +149,6 @@ func _main(cs colorScheme) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func userToEmail(email string) (string, error) {
|
||||
// TODO shell out to /town/src/town/cmd/usertoemail
|
||||
// TODO add to sudoers
|
||||
return "", nil
|
||||
}
|
||||
|
||||
func collectEmail(db *sql.DB, cs colorScheme, p *Prompter) error {
|
||||
fmt.Println(cs.Header("We can send a authorization code to an email associated with your town account."))
|
||||
email, err := p.String("email to send reset code to?")
|
||||
|
@ -289,6 +274,11 @@ func redeemCode(db *sql.DB, cs colorScheme, p *Prompter) error {
|
|||
return errors.New("adding to keys file failed")
|
||||
}
|
||||
|
||||
// TODO add help user
|
||||
// TODO update sshd_config
|
||||
// TODO update sudoers
|
||||
// TODO compile appendkeyfile and add to /town/bin/
|
||||
|
||||
err = code.MarkUsed(db)
|
||||
if err != nil {
|
||||
// TODO log err
|
||||
|
@ -298,13 +288,6 @@ func redeemCode(db *sql.DB, cs colorScheme, p *Prompter) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// TODO db plan:
|
||||
|
||||
// add new db, codes (modeled after invites)
|
||||
// add new helper, emailtouser, that can access town.db and report on what user matches a given email
|
||||
// drop table from town.db
|
||||
// update sshapps.md
|
||||
|
||||
func main() {
|
||||
cs := newColorScheme()
|
||||
err := _main(cs)
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
CREATE TABLE IF NOT EXISTS auth_codes (
|
||||
id INTEGER PRIMARY KEY,
|
||||
created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')),
|
||||
code TEXT,
|
||||
email TEXT,
|
||||
used INTEGER DEFAULT 0
|
||||
);
|
|
@ -32,3 +32,11 @@ CREATE TABLE IF NOT EXISTS notes (
|
|||
|
||||
FOREIGN KEY (author) REFERENCES users(author)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS auth_codes (
|
||||
id INTEGER PRIMARY KEY,
|
||||
created TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M', 'now', 'localtime')),
|
||||
code TEXT,
|
||||
email TEXT,
|
||||
used INTEGER DEFAULT 0
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue