2022-04-12 14:20:17 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/command/preparation"
|
|
|
|
"github.com/zitadel/zitadel/internal/crypto"
|
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2022-04-12 14:20:17 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Email struct {
|
|
|
|
Address string
|
|
|
|
Verified bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (e *Email) Valid() bool {
|
|
|
|
return e.Address != "" && domain.EmailRegex.MatchString(e.Address)
|
|
|
|
}
|
|
|
|
|
|
|
|
func newEmailCode(ctx context.Context, filter preparation.FilterToQueryReducer, alg crypto.EncryptionAlgorithm) (value *crypto.CryptoValue, expiry time.Duration, err error) {
|
|
|
|
return newCryptoCodeWithExpiry(ctx, filter, domain.SecretGeneratorTypeVerifyEmailCode, alg)
|
|
|
|
}
|