From c946148d1cbd69333d34b85aa3ab0fab3b6cc0d7 Mon Sep 17 00:00:00 2001 From: David Florness Date: Thu, 25 Jun 2020 13:38:55 -0600 Subject: [PATCH] Exit tallyard if user doesn't give inputs in TUI forms --- ui.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ui.go b/ui.go index 884ac26..aa2f177 100644 --- a/ui.go +++ b/ui.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "os" "sort" "strconv" "unicode" @@ -17,9 +18,18 @@ func tui() (election *Election, merkleRoot []byte, electionKey string) { switch buttonLabel { case "Create Election": election.candidates = createElection() + // TODO: slaves should check that len candidates >= 2 + if election.candidates == nil || len(election.candidates) == 0 { + fmt.Printf("no candidates entered; exiting\n") + os.Exit(0) + } merkleRoot = election.createMerkle(election.candidates) case "Join Election": electionKey := joinElection() + if electionKey == "" { + fmt.Printf("no election key given; exiting\n") + os.Exit(0) + } merkleRoot, election.masterID = splitElectionKey(electionKey) } } -- 2.38.4