Files
zitadel/backend/v3/domain/set_email.go

75 lines
2.0 KiB
Go
Raw Normal View History

2025-04-29 06:03:47 +02:00
package domain
// import (
// "context"
2025-04-29 06:03:47 +02:00
// "github.com/zitadel/zitadel/backend/v3/storage/eventstore"
// )
2025-04-29 06:03:47 +02:00
// // SetEmailCommand sets the email address of a user.
// // If allows verification as a sub command.
// // The verification command is executed after the email address is set.
// // The verification command is executed in the same transaction as the email address update.
// type SetEmailCommand struct {
// UserID string `json:"userId"`
// Email string `json:"email"`
// verification Commander
// }
2025-04-29 06:03:47 +02:00
// var (
// _ Commander = (*SetEmailCommand)(nil)
// _ eventer = (*SetEmailCommand)(nil)
// _ CreateHumanOpt = (*SetEmailCommand)(nil)
// )
2025-04-29 06:03:47 +02:00
// type SetEmailOpt interface {
// applyOnSetEmail(*SetEmailCommand)
// }
2025-04-29 06:03:47 +02:00
// func NewSetEmailCommand(userID, email string, verificationType SetEmailOpt) *SetEmailCommand {
// cmd := &SetEmailCommand{
// UserID: userID,
// Email: email,
// }
// verificationType.applyOnSetEmail(cmd)
// return cmd
// }
2025-04-29 06:03:47 +02:00
// // String implements [Commander].
// func (cmd *SetEmailCommand) String() string {
// return "SetEmailCommand"
// }
2025-05-08 15:30:06 +02:00
// func (cmd *SetEmailCommand) Execute(ctx context.Context, opts *CommandOpts) error {
// close, err := opts.EnsureTx(ctx)
// if err != nil {
// return err
// }
// defer func() { err = close(ctx, err) }()
// // userStatement(opts.DB).Human().ByID(cmd.UserID).SetEmail(ctx, cmd.Email)
// repo := userRepo(opts.DB).Human()
// err = repo.Update(ctx, repo.IDCondition(cmd.UserID), repo.SetEmailAddress(cmd.Email))
// if err != nil {
// return err
// }
2025-04-29 06:03:47 +02:00
// return opts.Invoke(ctx, cmd.verification)
// }
2025-04-29 06:03:47 +02:00
// // Events implements [eventer].
// func (cmd *SetEmailCommand) Events() []*eventstore.Event {
// return []*eventstore.Event{
// {
// AggregateType: "user",
// AggregateID: cmd.UserID,
// Type: "user.email.set",
// Payload: cmd,
// },
// }
// }
2025-04-29 06:03:47 +02:00
// // applyOnCreateHuman implements [CreateHumanOpt].
// func (cmd *SetEmailCommand) applyOnCreateHuman(createUserCmd *CreateUserCommand) {
// createUserCmd.email = cmd
// }