feat: add notification policy and password change message (#5065)

Implementation of new notification policy with functionality to send email when a password is changed
This commit is contained in:
Stefan Benz
2023-01-25 09:49:41 +01:00
committed by GitHub
parent 8b5894c0bb
commit 19621acfd3
73 changed files with 4196 additions and 83 deletions

View File

@@ -0,0 +1,31 @@
package command
import (
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/eventstore"
"github.com/zitadel/zitadel/internal/repository/policy"
)
type NotificationPolicyWriteModel struct {
eventstore.WriteModel
PasswordChange bool
State domain.PolicyState
}
func (wm *NotificationPolicyWriteModel) Reduce() error {
for _, event := range wm.Events {
switch e := event.(type) {
case *policy.NotificationPolicyAddedEvent:
wm.PasswordChange = e.PasswordChange
wm.State = domain.PolicyStateActive
case *policy.NotificationPolicyChangedEvent:
if e.PasswordChange != nil {
wm.PasswordChange = *e.PasswordChange
}
case *policy.NotificationPolicyRemovedEvent:
wm.State = domain.PolicyStateRemoved
}
}
return wm.WriteModel.Reduce()
}