feat(mail): send service identity mail through a leased worker
This commit is contained in:
1 parent
204c6bae62
commit
d21fd49a42
58 files changed
+7577
-164
No files matched your search
@@ -10,21 +10,26 @@ import (
|
||||
|
||||
var ErrInvalidEmailToken = errors.New("invalid email token")
|
||||
|
||||
// EmailTokenPurpose names what an email token authorizes. New purposes, such
|
||||
// as a planned password reset, are added here and in the email_tokens CHECK
|
||||
// constraint together.
|
||||
// EmailTokenPurpose names what an email token authorizes. New purposes are
|
||||
// added here and in the email_tokens CHECK constraint together.
|
||||
type EmailTokenPurpose string
|
||||
|
||||
// EmailTokenPurposeEmailVerification authorizes confirming the account email.
|
||||
const EmailTokenPurposeEmailVerification EmailTokenPurpose = "email_verification" //nolint:gosec // A purpose name, not a credential.
|
||||
const (
|
||||
// EmailTokenPurposeEmailVerification authorizes confirming the account
|
||||
// email.
|
||||
EmailTokenPurposeEmailVerification EmailTokenPurpose = "email_verification" //nolint:gosec // A purpose name, not a credential.
|
||||
// EmailTokenPurposePasswordReset authorizes setting a new password.
|
||||
EmailTokenPurposePasswordReset EmailTokenPurpose = "password_reset"
|
||||
)
|
||||
|
||||
// ParseEmailTokenPurpose accepts a known purpose.
|
||||
func ParseEmailTokenPurpose(value string) (EmailTokenPurpose, error) {
|
||||
purpose := EmailTokenPurpose(value)
|
||||
if purpose != EmailTokenPurposeEmailVerification {
|
||||
switch purpose := EmailTokenPurpose(value); purpose {
|
||||
case EmailTokenPurposeEmailVerification, EmailTokenPurposePasswordReset:
|
||||
return purpose, nil
|
||||
default:
|
||||
return "", fmt.Errorf("domain.ParseEmailTokenPurpose - unknown purpose: %w", ErrInvalidEmailToken)
|
||||
}
|
||||
return purpose, nil
|
||||
}
|
||||
|
||||
// EmailToken is the stored record of a one-time token sent by email. It holds
|
||||
|
||||
Reference in new issue
Block a user