From 2024e1879558d6f764251d32786b0ab9d9dc9db0 Mon Sep 17 00:00:00 2001 From: Alex Kalyvitis Date: Tue, 18 Sep 2018 14:52:56 +0200 Subject: [PATCH] fix email template delete --- auth0/resource_auth0_email_template.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/auth0/resource_auth0_email_template.go b/auth0/resource_auth0_email_template.go index 9a20224b..00ccbdd0 100644 --- a/auth0/resource_auth0_email_template.go +++ b/auth0/resource_auth0_email_template.go @@ -115,12 +115,20 @@ func readEmailTemplate(d *schema.ResourceData, m interface{}) error { func updateEmailTemplate(d *schema.ResourceData, m interface{}) error { e := buildEmailTemplate(d) api := m.(*management.Management) - return api.EmailTemplate.Replace(auth0.StringValue(e.Template), e) + err := api.EmailTemplate.Replace(auth0.StringValue(e.Template), e) + if err != nil { + return err + } + return readEmailTemplate(d, m) } func deleteEmailTemplate(d *schema.ResourceData, m interface{}) error { - d.Set("enabled", false) - return updateEmailTemplate(d, m) + api := m.(*management.Management) + t := &management.EmailTemplate{ + Template: auth0.String(d.Id()), + Enabled: auth0.Bool(false), + } + return api.EmailTemplate.Update(d.Id(), t) } func buildEmailTemplate(d *schema.ResourceData) *management.EmailTemplate {