diff --git a/grading_data_generator.go b/grading_data_generator.go index ed45b6e..490c865 100644 --- a/grading_data_generator.go +++ b/grading_data_generator.go @@ -7,6 +7,7 @@ import ( "log" "math/rand" "os" + "strings" "github.com/brianvoe/gofakeit/v6" ) @@ -485,11 +486,14 @@ var course_information = []Section{ } type User struct { - UID string `json:"uid"` - FirstName string `json:"first_name"` - LastName string `json:"last_name"` - Status string `json:"status"` - ExamID string `json:"exam_id"` + UID string `json:"uid"` + FirstName string `json:"first_name"` + LastName string `json:"last_name"` + Status string `json:"status"` + ExamID string `json:"exam_id"` + Username string `json:"username"` + APIKey string `json:"api_key"` + PasswordHash string `json:"password_hash"` } type Section struct { @@ -526,11 +530,13 @@ func GenerateUserData(config Config) []User { users := make([]User, config.NumberOfUsers) for i := range users { users[i] = User{ - UID: uids[i], - FirstName: gofakeit.FirstName(), - LastName: gofakeit.LastName(), - Status: weightedStatuses[rand.Intn(len(weightedStatuses))], - ExamID: examIDs[i], + UID: uids[i], + FirstName: gofakeit.FirstName(), + LastName: gofakeit.LastName(), + Status: weightedStatuses[rand.Intn(len(weightedStatuses))], + ExamID: examIDs[i], + APIKey: strings.ReplaceAll(gofakeit.UUID(), "-", ""), + PasswordHash: gofakeit.Password(true, true, true, true, false, 16), } } @@ -547,11 +553,11 @@ func SaveGeneratedUsers(users []User) { defer f.Close() w := csv.NewWriter(f) - if err := w.Write([]string{"uid", "first_name", "last_name", "status", "exam_id"}); err != nil { + if err := w.Write([]string{"uid", "first_name", "last_name", "status", "exam_id", "api_key", "password_hash"}); err != nil { log.Fatalf("failed to write csv header: %v", err) } for _, u := range users { - if err := w.Write([]string{u.UID, u.FirstName, u.LastName, u.Status, u.ExamID}); err != nil { + if err := w.Write([]string{u.UID, u.FirstName, u.LastName, u.Status, u.ExamID, u.APIKey, u.PasswordHash}); err != nil { log.Fatalf("failed to write csv row: %v", err) } } diff --git a/prompts/add_apikey_passwordhash.md b/prompts/add_apikey_passwordhash.md new file mode 100644 index 0000000..d334d99 --- /dev/null +++ b/prompts/add_apikey_passwordhash.md @@ -0,0 +1 @@ +Modify the GenerateUserData function to include the PasswordHash and APIKey fields. APIKey should be a v4 uuid with no dashes. Password should use gofaker's password generator. Modify SaveGeneratedUsers to include these columns in the csv file. diff --git a/sample_config.json b/sample_config.json index 12ba4bc..839acc0 100644 --- a/sample_config.json +++ b/sample_config.json @@ -12,6 +12,8 @@ "MLS": 0, "SPEC": 5, "MNR": 0, - "CERT": 5 + "CERT": 5, + "Admin": 0, + "Instructor": 0 } }