refactor: switch to a verification link
This commit is contained in:
parent
90cdcd16af
commit
cf83dc6767
|
@ -5,6 +5,7 @@ import (
|
||||||
"crypto/ed25519"
|
"crypto/ed25519"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-sql-driver/mysql"
|
"github.com/go-sql-driver/mysql"
|
||||||
|
@ -27,6 +28,8 @@ var (
|
||||||
ErrInvalidOTPCode = errors.New("Invalid OTP code")
|
ErrInvalidOTPCode = errors.New("Invalid OTP code")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const ACCOUNT_SUBDOMAIN = "account"
|
||||||
|
|
||||||
type AccountServiceParams struct {
|
type AccountServiceParams struct {
|
||||||
fx.In
|
fx.In
|
||||||
Db *gorm.DB
|
Db *gorm.DB
|
||||||
|
@ -144,10 +147,12 @@ func (s AccountServiceDefault) SendEmailVerification(userId uint) error {
|
||||||
return NewAccountError(ErrKeyDatabaseOperationFailed, err)
|
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{}{
|
vars := map[string]interface{}{
|
||||||
"FirstName": user.FirstName,
|
"FirstName": user.FirstName,
|
||||||
"Email": user.Email,
|
"Email": user.Email,
|
||||||
"VerificationCode": token,
|
"VerificationLink": verifyUrl,
|
||||||
"ExpireTime": verification.ExpiresAt.Sub(time.Now()).Round(time.Second * 2),
|
"ExpireTime": verification.ExpiresAt.Sub(time.Now()).Round(time.Second * 2),
|
||||||
"PortalName": s.config.Config().Core.PortalName,
|
"PortalName": s.config.Config().Core.PortalName,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
Dear {{if .FirstName}}{{.FirstName}}{{else}}{{.Email}}{{end}},
|
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,
|
Best regards,
|
||||||
The {{.PortalName}} Team
|
The {{.PortalName}} Team
|
||||||
|
|
Loading…
Reference in New Issue