fix: corrected statement to when an init code has to be sent (#4817)

* fix: corrected statement to when an init code has to be sent

* fix: corrected statement to when an init code has to be sent

* fix: corrected statement to when an init code has to be sent

* fix: add init code to user handle for auth.users2

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Stefan Benz
2022-12-07 11:16:01 +00:00
committed by GitHub
parent 2209187a48
commit a3f15d8213
2 changed files with 8 additions and 3 deletions

View File

@@ -193,6 +193,9 @@ func AddHumanCommand(a *user.Aggregate, human *AddHuman, passwordAlg crypto.Hash
cmds := make([]eventstore.Command, 0, 3)
cmds = append(cmds, createCmd)
if human.Email.Verified {
cmds = append(cmds, user.NewHumanEmailVerifiedEvent(ctx, &a.Aggregate))
}
//add init code if
// email not verified or
// user not registered and password set
@@ -203,9 +206,7 @@ func AddHumanCommand(a *user.Aggregate, human *AddHuman, passwordAlg crypto.Hash
}
cmds = append(cmds, user.NewHumanInitialCodeAddedEvent(ctx, &a.Aggregate, value, expiry))
} else {
if human.Email.Verified {
cmds = append(cmds, user.NewHumanEmailVerifiedEvent(ctx, &a.Aggregate))
} else {
if !human.Email.Verified {
value, expiry, err := newEmailCode(ctx, filter, codeAlg)
if err != nil {
return nil, err