mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
26c8113930
* feat: change user command side * feat: change user command side * feat: use states on write model * feat: command and query side in auth api * feat: auth commands * feat: check external idp id * feat: user state check * fix: error messages * fix: is active state
37 lines
662 B
Go
37 lines
662 B
Go
package domain
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/crypto"
|
|
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
|
"time"
|
|
)
|
|
|
|
type Email struct {
|
|
es_models.ObjectRoot
|
|
|
|
EmailAddress string
|
|
IsEmailVerified bool
|
|
}
|
|
|
|
type EmailCode struct {
|
|
es_models.ObjectRoot
|
|
|
|
Code *crypto.CryptoValue
|
|
Expiry time.Duration
|
|
}
|
|
|
|
func (e *Email) IsValid() bool {
|
|
return e.EmailAddress != ""
|
|
}
|
|
|
|
func NewEmailCode(emailGenerator crypto.Generator) (*EmailCode, error) {
|
|
emailCodeCrypto, _, err := crypto.NewCode(emailGenerator)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &EmailCode{
|
|
Code: emailCodeCrypto,
|
|
Expiry: emailGenerator.Expiry(),
|
|
}, nil
|
|
}
|