VAULT-6433 do not return nil resp if ns is nil (#16937)

* VAULT-6433 do not return nil resp if ns is nil

* VAULT-6433 typo
This commit is contained in:
Violet Hynes
2022-08-30 13:53:41 -04:00
committed by GitHub
parent 82174f0c0d
commit 094c6945f5

View File

@@ -1362,10 +1362,12 @@ func (b *LoginMFABackend) mfaLoginEnforcementConfigToMap(eConfig *mfa.MFAEnforce
resp := make(map[string]interface{})
resp["name"] = eConfig.Name
ns, err := b.namespacer.NamespaceByID(context.Background(), eConfig.NamespaceID)
if ns == nil || err != nil {
if err != nil {
return nil, err
}
resp["namespace_path"] = ns.Path
if ns != nil {
resp["namespace_path"] = ns.Path
}
resp["namespace_id"] = eConfig.NamespaceID
resp["mfa_method_ids"] = append([]string{}, eConfig.MFAMethodIDs...)
resp["auth_method_accessors"] = append([]string{}, eConfig.AuthMethodAccessors...)
@@ -1423,10 +1425,12 @@ func (b *MFABackend) mfaConfigToMap(mConfig *mfa.Config) (map[string]interface{}
respData["name"] = mConfig.Name
respData["namespace_id"] = mConfig.NamespaceID
ns, err := b.namespacer.NamespaceByID(context.Background(), mConfig.NamespaceID)
if ns == nil || err != nil {
if err != nil {
return nil, err
}
respData["namespace_path"] = ns.Path
if ns != nil {
respData["namespace_path"] = ns.Path
}
return respData, nil
}