Browse Source

Merge pull request #1824 from gravitl/story/GRA-795

fixed bugs around user update & user delete false error with no nets
dcarns 2 years ago
parent
commit
58725d242f
1 changed files with 7 additions and 2 deletions
  1. 7 2
      logic/auth.go

+ 7 - 2
logic/auth.go

@@ -283,7 +283,8 @@ func UpdateUser(userchange models.User, user models.User) (models.User, error) {
 
 
 		user.Password = userchange.Password
 		user.Password = userchange.Password
 	}
 	}
-	if userchange.IsAdmin != user.IsAdmin {
+
+	if (userchange.IsAdmin != user.IsAdmin) && !user.IsAdmin {
 		user.IsAdmin = userchange.IsAdmin
 		user.IsAdmin = userchange.IsAdmin
 	}
 	}
 
 
@@ -340,7 +341,11 @@ func DeleteUser(user string) (bool, error) {
 	// == pro - remove user from all network user instances ==
 	// == pro - remove user from all network user instances ==
 	currentNets, err := GetNetworks()
 	currentNets, err := GetNetworks()
 	if err != nil {
 	if err != nil {
-		return true, err
+		if database.IsEmptyRecord(err) {
+			currentNets = []models.Network{}
+		} else {
+			return true, err
+		}
 	}
 	}
 
 
 	for i := range currentNets {
 	for i := range currentNets {