From 9c013ac49406e17e1af0641638a6f2de21fec214 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Mon, 4 Sep 2023 10:50:21 +0800 Subject: [PATCH] fix --- html_template/email_register.tpl | 19 +++++++++++++++ server/auth/auth_test.go | 26 ++++++++++++++++++++- server/auth/internal/logic/email_manager.go | 23 ++---------------- 3 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 html_template/email_register.tpl diff --git a/html_template/email_register.tpl b/html_template/email_register.tpl new file mode 100644 index 00000000..703b8f5a --- /dev/null +++ b/html_template/email_register.tpl @@ -0,0 +1,19 @@ +Subject: Please confirm your {{.CompanyName}} account + +Dear , + +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 + +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! + +Regards, + +{{.SenderName}} +{{.SenderTitle}} +{{.CompanyName}} \ No newline at end of file diff --git a/server/auth/auth_test.go b/server/auth/auth_test.go index ef649768..e8b63634 100644 --- a/server/auth/auth_test.go +++ b/server/auth/auth_test.go @@ -1,7 +1,31 @@ package main -import "testing" +import ( + "testing" +) + +const emailTemplate = `Subject: Please confirm your {{CompanyName}} account + +Dear , + +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 + +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! + +Regards, + +{{SenderName}} +{{SenderTitle}} +{{CompanyName}} +` 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 5a5eaf50..6a678386 100644 --- a/server/auth/internal/logic/email_manager.go +++ b/server/auth/internal/logic/email_manager.go @@ -147,28 +147,9 @@ func (m *EmailSender) ClearExpiredTasks() { } } -const emailTemplate = `Subject: Your {{.CompanyName}} Account Confirmation - -Dear - -Thank you for creating an account with {{.CompanyName}}. We're excited to have you on board! - -Before we get started, we just need to confirm that this is the right email address. Please confirm your email address by clicking on the link below: - -{{.ConfirmationLink}} - -Once you've confirmed, you can get started with {{.CompanyName}}. If you have any questions, feel free to reply to this email. We're here to help! - -If you did not create an account with us, please ignore this email. - -Thanks, -{{.SenderName}} -{{.SenderTitle}} -{{.CompanyName}} -` - func RenderEmailTemplate(companyName, confirmationLink, senderName, senderTitle string) []byte { - tmpl, err := template.New("email").Parse(emailTemplate) + + tmpl, err := template.New("email").ParseFiles("../../html_template/email_register.tpl") if err != nil { log.Fatal(err) }