mirror of
https://github.com/zitadel/zitadel.git
synced 2025-05-22 13:38:19 +00:00

* add setup steps * refactoring * omitempty * cleanup * begin org * create org * setup org * setup org * merge * fixes * fixes * fixes * add project * add oidc application * fix app creation * add resourceOwner to writemodels * resource owner * cleanup * global org, iam project and iam member in setup * logs * logs * logs * cleanup * Update internal/v2/command/project.go Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com> * check project state * add org domain commands * add org status changes and member commands * fixes * policies * login policy * fix iam project event * mapper * label policy * change to command * fix * fix * handle change event differently and lot of fixes * fixes * changedEvent handling Co-authored-by: Fabi <38692350+fgerschwiler@users.noreply.github.com>
80 lines
2.1 KiB
Go
80 lines
2.1 KiB
Go
package command
|
|
|
|
import (
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/v2/domain"
|
|
"github.com/caos/zitadel/internal/v2/repository/iam"
|
|
)
|
|
|
|
type IAMSecondFactorWriteModel struct {
|
|
SecondFactorWriteModel
|
|
}
|
|
|
|
func NewIAMSecondFactorWriteModel() *IAMSecondFactorWriteModel {
|
|
return &IAMSecondFactorWriteModel{
|
|
SecondFactorWriteModel{
|
|
WriteModel: eventstore.WriteModel{
|
|
AggregateID: domain.IAMID,
|
|
ResourceOwner: domain.IAMID,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func (wm *IAMSecondFactorWriteModel) AppendEvents(events ...eventstore.EventReader) {
|
|
for _, event := range events {
|
|
switch e := event.(type) {
|
|
case *iam.LoginPolicySecondFactorAddedEvent:
|
|
wm.WriteModel.AppendEvents(&e.SecondFactorAddedEvent)
|
|
case *iam.LoginPolicySecondFactorRemovedEvent:
|
|
wm.WriteModel.AppendEvents(&e.SecondFactorRemovedEvent)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (wm *IAMSecondFactorWriteModel) Reduce() error {
|
|
return wm.WriteModel.Reduce()
|
|
}
|
|
|
|
func (wm *IAMSecondFactorWriteModel) Query() *eventstore.SearchQueryBuilder {
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
|
|
AggregateIDs(wm.WriteModel.AggregateID).
|
|
ResourceOwner(wm.ResourceOwner)
|
|
}
|
|
|
|
type IAMMultiFactorWriteModel struct {
|
|
MultiFactoryWriteModel
|
|
}
|
|
|
|
func NewIAMMultiFactorWriteModel() *IAMMultiFactorWriteModel {
|
|
return &IAMMultiFactorWriteModel{
|
|
MultiFactoryWriteModel{
|
|
WriteModel: eventstore.WriteModel{
|
|
AggregateID: domain.IAMID,
|
|
ResourceOwner: domain.IAMID,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func (wm *IAMMultiFactorWriteModel) AppendEvents(events ...eventstore.EventReader) {
|
|
for _, event := range events {
|
|
switch e := event.(type) {
|
|
case *iam.LoginPolicyMultiFactorAddedEvent:
|
|
wm.WriteModel.AppendEvents(&e.MultiFactorAddedEvent)
|
|
case *iam.LoginPolicyMultiFactorRemovedEvent:
|
|
wm.WriteModel.AppendEvents(&e.MultiFactorRemovedEvent)
|
|
}
|
|
}
|
|
}
|
|
|
|
func (wm *IAMMultiFactorWriteModel) Reduce() error {
|
|
return wm.WriteModel.Reduce()
|
|
}
|
|
|
|
func (wm *IAMMultiFactorWriteModel) Query() *eventstore.SearchQueryBuilder {
|
|
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent, iam.AggregateType).
|
|
AggregateIDs(wm.WriteModel.AggregateID).
|
|
ResourceOwner(wm.ResourceOwner)
|
|
}
|