Allow empty groups for DNS setting (#656)

We should allow passing empty group slice for DisabledManagementGroups to reset any setting.


Fix DNS settings activities message
This commit is contained in:
Maycon Santos 2023-01-18 14:01:50 +01:00 committed by GitHub
parent dcf6533ed5
commit 793e4f1f29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -97,9 +97,9 @@ const (
// GroupRemovedFromSetupKeyMessage is a human-readable text message of the GroupRemovedFromSetupKey activity
GroupRemovedFromSetupKeyMessage string = "Group removed from user setup key"
// GroupAddedToDisabledManagementGroupsMessage is a human-readable text message of the GroupAddedToDisabledManagementGroups activity
GroupAddedToDisabledManagementGroupsMessage
GroupAddedToDisabledManagementGroupsMessage string = "Group added to disabled management DNS setting"
// GroupRemovedFromDisabledManagementGroupsMessage is a human-readable text message of the GroupRemovedFromDisabledManagementGroups activity
GroupRemovedFromDisabledManagementGroupsMessage
GroupRemovedFromDisabledManagementGroupsMessage string = "Group removed from disabled management DNS setting"
)
// Activity that triggered an Event

View File

@ -87,9 +87,11 @@ func (am *DefaultAccountManager) SaveDNSSettings(accountID string, userID string
return status.Errorf(status.InvalidArgument, "the dns settings provided are nil")
}
err = validateGroups(dnsSettingsToSave.DisabledManagementGroups, account.Groups)
if err != nil {
return err
if len(dnsSettingsToSave.DisabledManagementGroups) != 0 {
err = validateGroups(dnsSettingsToSave.DisabledManagementGroups, account.Groups)
if err != nil {
return err
}
}
oldSettings := &DNSSettings{}