瀏覽代碼

if -- else to determine type

Matthew R Kasun 2 年之前
父節點
當前提交
33249f37ac
共有 1 個文件被更改,包括 2 次插入4 次删除
  1. 2 4
      logic/enrollmentkey.go

+ 2 - 4
logic/enrollmentkey.go

@@ -46,12 +46,10 @@ func CreateEnrollmentKey(uses int, expiration time.Time, networks, tags []string
 	if uses > 0 {
 	if uses > 0 {
 		k.UsesRemaining = uses
 		k.UsesRemaining = uses
 		k.Type = models.Uses
 		k.Type = models.Uses
-	}
-	if !expiration.IsZero() {
+	} else if !expiration.IsZero() {
 		k.Expiration = expiration
 		k.Expiration = expiration
 		k.Type = models.TimeExpiration
 		k.Type = models.TimeExpiration
-	}
-	if k.Unlimited {
+	} else if k.Unlimited {
 		k.Type = models.Unlimited
 		k.Type = models.Unlimited
 	}
 	}
 	if len(networks) > 0 {
 	if len(networks) > 0 {