diff --git a/html_template/email_register.tpl b/html_template/email_register.tpl
index 703b8f5a..353f01fe 100644
--- a/html_template/email_register.tpl
+++ b/html_template/email_register.tpl
@@ -1,19 +1,19 @@
-Subject: Please confirm your {{.CompanyName}} account
+Subject: Please confirm your {{ .CompanyName }} account
-Dear ,
+Dear,
-Thank you for registering an account with {{.CompanyName}}. We are thrilled to have you join our community!
+Thank you for registering an account with {{ .CompanyName }}. We are thrilled to have you join our community!
Please take a moment to confirm your email address by clicking the button below so we can activate your account:
-Confirm My Account
+Confirm My Account
Confirming your email ensures your account is properly secured. This also lets you access member-only tools and content.
-If you did not register for {{.CompanyName}}, please disregard this email. Let us know if you have any other questions!
+If you did not register for {{ .CompanyName }}, please disregard this email. Let us know if you have any other questions!
Regards,
-{{.SenderName}}
-{{.SenderTitle}}
-{{.CompanyName}}
\ No newline at end of file
+{{ .SenderName }}
+{{ .SenderTitle }}
+{{ .CompanyName }}
\ No newline at end of file
diff --git a/server/auth/auth_test.go b/server/auth/auth_test.go
index 80820ef2..9f5d2cd8 100644
--- a/server/auth/auth_test.go
+++ b/server/auth/auth_test.go
@@ -5,5 +5,6 @@ import (
)
func TestMain(t *testing.T) {
+
main()
}
diff --git a/server/auth/internal/logic/email_manager.go b/server/auth/internal/logic/email_manager.go
index 8c0adfab..5cefe8c3 100644
--- a/server/auth/internal/logic/email_manager.go
+++ b/server/auth/internal/logic/email_manager.go
@@ -16,15 +16,15 @@ var EmailTaskResendTime = time.Second * 30
var TimeLimit *check.TimeLimit[string]
var EmailManager *EmailSender
-var emailTpl *template.Template
+var tpls *template.Template
func init() {
+ var err error
- tmpl, err := template.New("email").ParseFiles("../../html_template/email_register.tpl")
+ tpls, err = template.ParseGlob("../../../../html_template/*.tpl")
if err != nil {
log.Fatal(err)
}
- emailTpl = tmpl
TimeLimit = check.NewTimelimit[string](EmailTaskResendTime)
@@ -165,7 +165,7 @@ func RenderEmailTemplate(companyName, confirmationLink, senderName, senderTitle
}
var result bytes.Buffer
- err := emailTpl.Execute(&result, data)
+ err := tpls.ExecuteTemplate(&result, "email_register.tpl", data)
if err != nil {
log.Fatal(err)
}
diff --git a/server/auth/internal/logic/websocket_test.go b/server/auth/internal/logic/websocket_test.go
index da4fb0e0..25686261 100644
--- a/server/auth/internal/logic/websocket_test.go
+++ b/server/auth/internal/logic/websocket_test.go
@@ -1,6 +1,7 @@
package logic
import (
+ "bytes"
"fmt"
"fusenapi/utils/wevent"
"log"
@@ -11,6 +12,24 @@ import (
"github.com/zeromicro/go-zero/core/logx"
)
+func TestEmailTpl(t *testing.T) {
+ data := map[string]string{
+ "CompanyName": "companyName",
+ "ConfirmationLink": "confirmationLink",
+ "SenderName": "senderName",
+ "SenderTitle": "senderTitle",
+ }
+
+ var result bytes.Buffer
+ err := tpls.ExecuteTemplate(&result, "email_register.tpl", data)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ log.Println(string(result.String()))
+
+}
+
func TestSender(t *testing.T) {
traceId := uuid.NewString()
event := wevent.NewWebsocketEventSuccess(wevent.UserEmailRegister, traceId)
diff --git a/utils/fstpl/auto_parse.go b/utils/fstpl/auto_parse.go
new file mode 100644
index 00000000..347e3ff1
--- /dev/null
+++ b/utils/fstpl/auto_parse.go
@@ -0,0 +1,7 @@
+package fstpl
+
+import "html/template"
+
+func ParseFile(t *template.Template) {
+
+}