mirror of
https://github.com/zitadel/zitadel.git
synced 2025-04-28 15:50:54 +00:00

* fix: split command query side * fix: split command query side * fix: members in correct pkg structure * fix: label policy in correct pkg structure * fix: structure * fix: structure of login policy * fix: identityprovider structure * fix: org iam policy structure * fix: password age policy structure * fix: password complexity policy structure * fix: password lockout policy structure * fix: idp structure * fix: user events structure * fix: user write model * fix: profile email changed command * fix: address changed command * fix: user states * fix: user * fix: org structure and add human * begin iam setup command side * setup * step2 * step2 * fix: add user * step2 * isvalid * fix: folder structure v2 business Co-authored-by: Fabiennne <fabienne.gerschwiler@gmail.com>
104 lines
2.4 KiB
Go
104 lines
2.4 KiB
Go
package policy
|
|
|
|
import (
|
|
"encoding/json"
|
|
"github.com/caos/zitadel/internal/errors"
|
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
|
)
|
|
|
|
const (
|
|
LabelPolicyAddedEventType = "policy.label.added"
|
|
LabelPolicyChangedEventType = "policy.label.changed"
|
|
LabelPolicyRemovedEventType = "policy.label.removed"
|
|
)
|
|
|
|
type LabelPolicyAddedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
PrimaryColor string `json:"primaryColor,omitempty"`
|
|
SecondaryColor string `json:"secondaryColor,omitempty"`
|
|
}
|
|
|
|
func (e *LabelPolicyAddedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func NewLabelPolicyAddedEvent(
|
|
base *eventstore.BaseEvent,
|
|
primaryColor,
|
|
secondaryColor string,
|
|
) *LabelPolicyAddedEvent {
|
|
|
|
return &LabelPolicyAddedEvent{
|
|
BaseEvent: *base,
|
|
PrimaryColor: primaryColor,
|
|
SecondaryColor: secondaryColor,
|
|
}
|
|
}
|
|
|
|
func LabelPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &LabelPolicyAddedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "POLIC-puqv4", "unable to unmarshal label policy")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type LabelPolicyChangedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
PrimaryColor string `json:"primaryColor,omitempty"`
|
|
SecondaryColor string `json:"secondaryColor,omitempty"`
|
|
}
|
|
|
|
func (e *LabelPolicyChangedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func NewLabelPolicyChangedEvent(
|
|
base *eventstore.BaseEvent,
|
|
) *LabelPolicyChangedEvent {
|
|
return &LabelPolicyChangedEvent{
|
|
BaseEvent: *base,
|
|
}
|
|
}
|
|
|
|
func LabelPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &LabelPolicyChangedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "POLIC-qhfFb", "unable to unmarshal label policy")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type LabelPolicyRemovedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
}
|
|
|
|
func (e *LabelPolicyRemovedEvent) Data() interface{} {
|
|
return nil
|
|
}
|
|
|
|
func NewRemovedEvent(base *eventstore.BaseEvent) *LabelPolicyRemovedEvent {
|
|
return &LabelPolicyRemovedEvent{
|
|
BaseEvent: *base,
|
|
}
|
|
}
|
|
|
|
func RemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
return &LabelPolicyRemovedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}, nil
|
|
}
|