mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:07:31 +00:00
27 lines
598 B
Go
27 lines
598 B
Go
![]() |
package domain
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"github.com/zitadel/zitadel/internal/crypto"
|
||
|
)
|
||
|
|
||
|
type generateCodeCommand struct {
|
||
|
code string
|
||
|
value *crypto.CryptoValue
|
||
|
}
|
||
|
|
||
|
type CryptoRepository interface {
|
||
|
GetEncryptionConfig(ctx context.Context) (*crypto.GeneratorConfig, error)
|
||
|
}
|
||
|
|
||
|
func (cmd *generateCodeCommand) Execute(ctx context.Context, opts *CommandOpts) error {
|
||
|
config, err := cryptoRepo(opts.DB).GetEncryptionConfig(ctx)
|
||
|
if err != nil {
|
||
|
return err
|
||
|
}
|
||
|
generator := crypto.NewEncryptionGenerator(*config, userCodeAlgorithm)
|
||
|
cmd.value, cmd.code, err = crypto.NewCode(generator)
|
||
|
return err
|
||
|
}
|