refactor: switch to a verification link

This commit is contained in:
Derrick Hammer 2024-03-26 15:12:31 -04:00
parent 90cdcd16af
commit cf83dc6767
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 9 additions and 4 deletions

View File

@ -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,
}

View File

@ -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