feat(identity): confirm the email address with a six-digit code from the message

This commit is contained in:
shira committed 2026-10-10 00:52:46 +03:00
1 parent c94434cd09
commit d365a05c96
87 files changed
+4764 -224

No files matched your search

@@ -29,6 +29,11 @@ type TokenMailRequest struct {
// Lifetime is the validity of the token that the message states, in
// whole hours.
Lifetime domain.Hours
// Code is the six-digit code of an email verification message, and
// CodeLifetime its validity as the message states it. Both are required
// for email verification and unused by the other kinds.
Code domain.VerificationCode
CodeLifetime time.Duration
}
// ServiceMailer stores service mail of the account flows (email verification
@@ -65,7 +70,15 @@ func (mailer *ServiceMailer) EnqueueVerification(ctx context.Context, unit outbo
if err := checkTokenMailRequest(location, request, domain.EmailTokenPurposeEmailVerification); err != nil {
return uuid.Nil, err
}
content, err := mailer.renderer.RenderVerification(mailtemplate.VerificationData{Token: request.RawToken, TokenLifetime: request.Lifetime})
if request.Code.IsZero() {
return uuid.Nil, fmt.Errorf("%s - verification code must be set: %w", location, domain.ErrInvalidEmailToken)
}
content, err := mailer.renderer.RenderVerification(mailtemplate.VerificationData{
Token: request.RawToken,
TokenLifetime: request.Lifetime,
Code: request.Code,
CodeLifetime: request.CodeLifetime,
})
if err != nil {
return uuid.Nil, fmt.Errorf("%s - render message: %w", location, err)
}