diff --git a/examples/PasswordExpiryWatcher/passwordExpiryWatcher.go b/examples/PasswordExpiryWatcher/passwordExpiryWatcher.go index 5c529ad..3d72cb9 100644 --- a/examples/PasswordExpiryWatcher/passwordExpiryWatcher.go +++ b/examples/PasswordExpiryWatcher/passwordExpiryWatcher.go @@ -7,6 +7,7 @@ import ( "log" "os" "path/filepath" + "strconv" "time" "github.com/TheJumpCloud/jcapi" @@ -18,8 +19,8 @@ func main() { var csvFile string // Obtain the input parameters - flag.StringVar(&csvFile, "output", "o", "-output=") - flag.StringVar(&apiKey, "key", "k", "-key=") + flag.StringVar(&csvFile, "output", "", "-output=") + flag.StringVar(&apiKey, "key", "", "-key=") flag.Parse() if csvFile == "" || apiKey == "" { @@ -52,7 +53,7 @@ func main() { defer file.Close() w := csv.NewWriter(file) - if err := w.Write([]string{"FIRSTNAME", "LASTNAME", "EMAIL", "PASSWORD EXPIRY DATE", "PASSWORD EXPIRED"}); err != nil { + if err := w.Write([]string{"FIRSTNAME", "LASTNAME", "EMAIL", "PASSWORD EXPIRY DATE", "PASSWORD EXPIRED", "MFA ENABLED", "MFA VERIFIED"}); err != nil { log.Fatalln("error writing record to csv:", err) } @@ -69,7 +70,7 @@ func main() { } else { passwordExpirationString = record.PasswordExpirationDate.String() } - if err := w.Write([]string{record.FirstName, record.LastName, record.Email, passwordExpirationString, expired}); err != nil { + if err := w.Write([]string{record.FirstName, record.LastName, record.Email, passwordExpirationString, expired, strconv.FormatBool(record.EnableUserPortalMultifactor), strconv.FormatBool(record.TotpEnabled)}); err != nil { log.Fatalln("error writing record to csv:", err) } } diff --git a/jcapi-systemusers.go b/jcapi-systemusers.go index 15faa68..aeef270 100644 --- a/jcapi-systemusers.go +++ b/jcapi-systemusers.go @@ -14,23 +14,25 @@ type JCUserAttribute struct { // If you add a field here make sure to add corresponding logic to getJCUserFieldsFromInterface type JCUser struct { - Id string `json:"_id,omitempty"` - UserName string `json:"username,omitempty"` - FirstName string `json:"firstname,omitempty"` - LastName string `json:"lastname,omitempty"` - Email string `json:"email"` - Password string `json:"password,omitempty"` - PasswordDate string `json:"password_date,omitempty"` - Activated bool `json:"activated"` - ActivationKey string `json:"activation_key"` - ExpiredWarned bool `json:"expired_warned"` - PasswordExpired bool `json:"password_expired"` - PasswordExpirationDate time.Time `json:"password_expiration_date,omitempty"` - PendingProvisioning bool `json:"pendingProvisioning,omitempty"` - Sudo bool `json:"sudo"` - Uid string `json:"unix_uid"` - Gid string `json:"unix_guid"` - EnableManagedUid bool `json:"enable_managed_uid"` + Id string `json:"_id,omitempty"` + UserName string `json:"username,omitempty"` + FirstName string `json:"firstname,omitempty"` + LastName string `json:"lastname,omitempty"` + Email string `json:"email"` + Password string `json:"password,omitempty"` + PasswordDate string `json:"password_date,omitempty"` + Activated bool `json:"activated"` + ActivationKey string `json:"activation_key"` + ExpiredWarned bool `json:"expired_warned"` + PasswordExpired bool `json:"password_expired"` + PasswordExpirationDate time.Time `json:"password_expiration_date,omitempty"` + PendingProvisioning bool `json:"pendingProvisioning,omitempty"` + Sudo bool `json:"sudo"` + Uid string `json:"unix_uid"` + Gid string `json:"unix_guid"` + EnableManagedUid bool `json:"enable_managed_uid"` + EnableUserPortalMultifactor bool `json:"enable_user_portal_multifactor"` + TotpEnabled bool `json:"totp_enabled"` Attributes []JCUserAttribute `json:"attributes,omitempty"` @@ -164,6 +166,14 @@ func getJCUserFieldsFromInterface(fields map[string]interface{}, user *JCUser) e return err } } + + if _, exists := fields["enable_user_portal_multifactor"]; exists { + user.EnableUserPortalMultifactor = fields["enable_user_portal_multifactor"].(bool) + } + + if _, exists := fields["totp_enabled"]; exists { + user.TotpEnabled = fields["totp_enabled"].(bool) + } if attrs, exists := fields["attributes"]; exists { attributes := attrs.([]interface{})