diff --git a/account/account.go b/account/account.go index 57c4f7e..e83db91 100644 --- a/account/account.go +++ b/account/account.go @@ -5,6 +5,7 @@ import ( "crypto/ed25519" "crypto/rand" "errors" + "fmt" "time" "github.com/go-sql-driver/mysql" @@ -27,6 +28,8 @@ var ( ErrInvalidOTPCode = errors.New("Invalid OTP code") ) +const ACCOUNT_SUBDOMAIN = "account" + type AccountServiceParams struct { fx.In Db *gorm.DB @@ -144,10 +147,12 @@ func (s AccountServiceDefault) SendEmailVerification(userId uint) error { return NewAccountError(ErrKeyDatabaseOperationFailed, err) } + verifyUrl := fmt.Sprintf("%s://%s/account/verify?email=%s&token=%s", fmt.Sprintf("https://%s.%s", ACCOUNT_SUBDOMAIN, s.config.Config().Core.Domain), user.Email, token) + vars := map[string]interface{}{ "FirstName": user.FirstName, "Email": user.Email, - "VerificationCode": token, + "VerificationLink": verifyUrl, "ExpireTime": verification.ExpiresAt.Sub(time.Now()).Round(time.Second * 2), "PortalName": s.config.Config().Core.PortalName, } diff --git a/mailer/templates/verify_email_body.tpl b/mailer/templates/verify_email_body.tpl index cca465f..815ecb1 100644 --- a/mailer/templates/verify_email_body.tpl +++ b/mailer/templates/verify_email_body.tpl @@ -1,10 +1,10 @@ Dear {{if .FirstName}}{{.FirstName}}{{else}}{{.Email}}{{end}}, -Thank you for registering with {{.PortalName}}. To complete your registration and verify your email address, please enter the following verification code in the provided field on our website: +Thank you for registering with {{.PortalName}}. To complete your registration and verify your email address, please go to the following link: -Verification Code: {{.VerificationCode}} +{{.VerificationLink}} -Please note, this code will expire in {{.ExpireTime}}. If you did not initiate this request, please ignore this email or contact our support team for assistance. +Please note, this link will expire in {{.ExpireTime}}. If you did not initiate this request, please ignore this email or contact our support team for assistance. Best regards, The {{.PortalName}} Team