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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -147,6 +147,10 @@ func (u *User) ProcessUser(event *es_models.Event) (err error) {
user_repo.HumanMFAInitSkippedType,
user_repo.MachineChangedEventType,
user_repo.HumanPasswordChangedType,
user_repo.HumanInitialCodeAddedType,
user_repo.UserV1InitialCodeAddedType,
user_repo.UserV1InitializedCheckSucceededType,
user_repo.HumanInitializedCheckSucceededType,
user_repo.HumanPasswordlessInitCodeAddedType,
user_repo.HumanPasswordlessInitCodeRequestedType:
user, err = u.view.UserByID(event.AggregateID, event.InstanceID)

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