terrible no good massive refactor commit (oh yeah and built generic sessions for admin panel)
This commit is contained in:
parent
cee99a6932
commit
45f33b8b46
34 changed files with 740 additions and 654 deletions
18
main.go
18
main.go
|
@ -89,7 +89,7 @@ func main() {
|
|||
totpName := os.Args[3]
|
||||
secret := controller.GenerateTOTPSecret(controller.TOTP_SECRET_LENGTH)
|
||||
|
||||
account, err := controller.GetAccount(app.DB, username)
|
||||
account, err := controller.GetAccountByUsername(app.DB, username)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch account \"%s\": %v\n", username, err)
|
||||
os.Exit(1)
|
||||
|
@ -108,6 +108,10 @@ func main() {
|
|||
|
||||
err = controller.CreateTOTP(app.DB, &totp)
|
||||
if err != nil {
|
||||
if strings.HasPrefix(err.Error(), "pq: duplicate key") {
|
||||
fmt.Fprintf(os.Stderr, "Account \"%s\" already has a TOTP method named \"%s\"!\n", account.Username, totp.Name)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "Failed to create TOTP method: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
@ -124,7 +128,7 @@ func main() {
|
|||
username := os.Args[2]
|
||||
totpName := os.Args[3]
|
||||
|
||||
account, err := controller.GetAccount(app.DB, username)
|
||||
account, err := controller.GetAccountByUsername(app.DB, username)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch account \"%s\": %v\n", username, err)
|
||||
os.Exit(1)
|
||||
|
@ -151,7 +155,7 @@ func main() {
|
|||
}
|
||||
username := os.Args[2]
|
||||
|
||||
account, err := controller.GetAccount(app.DB, username)
|
||||
account, err := controller.GetAccountByUsername(app.DB, username)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch account \"%s\": %v\n", username, err)
|
||||
os.Exit(1)
|
||||
|
@ -184,7 +188,7 @@ func main() {
|
|||
username := os.Args[2]
|
||||
totpName := os.Args[3]
|
||||
|
||||
account, err := controller.GetAccount(app.DB, username)
|
||||
account, err := controller.GetAccountByUsername(app.DB, username)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch account \"%s\": %v\n", username, err)
|
||||
os.Exit(1)
|
||||
|
@ -240,6 +244,8 @@ func main() {
|
|||
}
|
||||
|
||||
for _, account := range accounts {
|
||||
email := "<none>"
|
||||
if account.Email.Valid { email = account.Email.String }
|
||||
fmt.Printf(
|
||||
"User: %s\n" +
|
||||
"\tID: %s\n" +
|
||||
|
@ -247,7 +253,7 @@ func main() {
|
|||
"\tCreated: %s\n",
|
||||
account.Username,
|
||||
account.ID,
|
||||
account.Email,
|
||||
email,
|
||||
account.CreatedAt,
|
||||
)
|
||||
}
|
||||
|
@ -261,7 +267,7 @@ func main() {
|
|||
username := os.Args[2]
|
||||
fmt.Printf("Deleting account \"%s\"...\n", username)
|
||||
|
||||
account, err := controller.GetAccount(app.DB, username)
|
||||
account, err := controller.GetAccountByUsername(app.DB, username)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fetch account \"%s\": %v\n", username, err)
|
||||
os.Exit(1)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue