mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-30 07:58:51 +00:00
New eventstore policies (#1084)
* feat: login policy * feat: password complexity policy * feat: org iam policy * feat: label policy * feat: add and change policies * feat: second factors * feat: second and multi factors * feat: better naming * feat: better naming
This commit is contained in:
@@ -1,83 +0,0 @@
|
||||
package iam
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
"github.com/caos/zitadel/internal/v2/repository/policy"
|
||||
)
|
||||
|
||||
var (
|
||||
LabelPolicyAddedEventType = iamEventTypePrefix + policy.LabelPolicyAddedEventType
|
||||
LabelPolicyChangedEventType = iamEventTypePrefix + policy.LabelPolicyChangedEventType
|
||||
)
|
||||
|
||||
type LabelPolicyReadModel struct{ policy.LabelPolicyReadModel }
|
||||
|
||||
func (rm *LabelPolicyReadModel) AppendEvents(events ...eventstore.EventReader) {
|
||||
for _, event := range events {
|
||||
switch e := event.(type) {
|
||||
case *LabelPolicyAddedEvent:
|
||||
rm.ReadModel.AppendEvents(&e.LabelPolicyAddedEvent)
|
||||
case *LabelPolicyChangedEvent:
|
||||
rm.ReadModel.AppendEvents(&e.LabelPolicyChangedEvent)
|
||||
case *policy.LabelPolicyAddedEvent, *policy.LabelPolicyChangedEvent:
|
||||
rm.ReadModel.AppendEvents(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type LabelPolicyAddedEvent struct {
|
||||
policy.LabelPolicyAddedEvent
|
||||
}
|
||||
|
||||
func LabelPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e, err := policy.LabelPolicyAddedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyAddedEvent{LabelPolicyAddedEvent: *e.(*policy.LabelPolicyAddedEvent)}, nil
|
||||
}
|
||||
|
||||
type LabelPolicyChangedEvent struct {
|
||||
policy.LabelPolicyChangedEvent
|
||||
}
|
||||
|
||||
func LabelPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e, err := policy.LabelPolicyChangedEventMapper(event)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &LabelPolicyChangedEvent{LabelPolicyChangedEvent: *e.(*policy.LabelPolicyChangedEvent)}, nil
|
||||
}
|
||||
|
||||
// func NewLabelPolicyAddedEvent(
|
||||
// ctx context.Context,
|
||||
// primaryColor,
|
||||
// secondaryColor string,
|
||||
// ) *LabelPolicyAddedEvent {
|
||||
|
||||
// return &LabelPolicyAddedEvent{
|
||||
// LabelPolicyAddedEvent: *policy.NewLabelPolicyAddedEvent(
|
||||
// ctx,
|
||||
// primaryColor,
|
||||
// secondaryColor,
|
||||
// ),
|
||||
// }
|
||||
// }
|
||||
|
||||
// func NewLabelPolicyChangedEvent(
|
||||
// ctx context.Context,
|
||||
// primaryColor,
|
||||
// secondaryColor string,
|
||||
// ) *MemberChangedEvent {
|
||||
|
||||
// return &LabelPolicyChangedEvent{
|
||||
// LabelPolicyChangedEvent: *policy.NewLabelPolicyChangedEvent(
|
||||
// ctx,
|
||||
// primaryColor,
|
||||
// secondaryColor,
|
||||
// ),
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user