Try to ListZones when validating providers settings
Bug: https://github.com/happyDomain/happydomain/issues/20
This commit is contained in:
parent
82067201f4
commit
fab386534c
|
@ -26,6 +26,7 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
dnscontrol "github.com/StackExchange/dnscontrol/v4/providers"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
"git.happydns.org/happyDomain/config"
|
"git.happydns.org/happyDomain/config"
|
||||||
|
@ -103,10 +104,22 @@ func getProviderSettingsState(cfg *config.Options, c *gin.Context) {
|
||||||
} else if cfg.DisableProviders {
|
} else if cfg.DisableProviders {
|
||||||
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Cannot change provider settings as DisableProviders parameter is set."})
|
c.AbortWithStatusJSON(http.StatusForbidden, gin.H{"errmsg": "Cannot change provider settings as DisableProviders parameter is set."})
|
||||||
return
|
return
|
||||||
} else if _, err = src.NewDNSServiceProvider(); err != nil {
|
}
|
||||||
|
|
||||||
|
p, err := src.NewDNSServiceProvider()
|
||||||
|
if err != nil {
|
||||||
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
return
|
return
|
||||||
} else if uss.Id == nil {
|
}
|
||||||
|
|
||||||
|
if sr, ok := p.(dnscontrol.ZoneLister); ok {
|
||||||
|
if _, err = sr.ListZones(); err != nil {
|
||||||
|
c.AbortWithStatusJSON(http.StatusBadRequest, gin.H{"errmsg": err.Error()})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if uss.Id == nil {
|
||||||
// Create a new Provider
|
// Create a new Provider
|
||||||
s, err := storage.MainStore.CreateProvider(user, src, uss.Name)
|
s, err := storage.MainStore.CreateProvider(user, src, uss.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -67,9 +67,19 @@ type ProviderCombined struct {
|
||||||
ProviderMeta
|
ProviderMeta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProviderCombined) Validate() (err error) {
|
// Validate ensure the given parameters are corrects.
|
||||||
_, err = p.NewDNSServiceProvider()
|
func (p *ProviderCombined) Validate() error {
|
||||||
return
|
prv, err := p.NewDNSServiceProvider()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
sr, ok := prv.(providers.ZoneLister)
|
||||||
|
if ok {
|
||||||
|
_, err = sr.ListZones()
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *ProviderCombined) getZoneRecords(fqdn string) (rcs models.Records, err error) {
|
func (p *ProviderCombined) getZoneRecords(fqdn string) (rcs models.Records, err error) {
|
||||||
|
|
Loading…
Reference in New Issue