mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-14 03:54:21 +00:00
65a8efeb0e
* fix: use pointer in events * fix: change user requests to command side * fix: org policy * fix: profile
79 lines
1.8 KiB
Go
79 lines
1.8 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 (
|
|
OrgIAMPolicyAddedEventType = "policy.org.iam.added"
|
|
OrgIAMPolicyChangedEventType = "policy.org.iam.changed"
|
|
)
|
|
|
|
type OrgIAMPolicyAddedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
UserLoginMustBeDomain bool `json:"userLoginMustBeDomain,omitempty"`
|
|
}
|
|
|
|
func (e *OrgIAMPolicyAddedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func NewOrgIAMPolicyAddedEvent(
|
|
base *eventstore.BaseEvent,
|
|
userLoginMustBeDomain bool,
|
|
) *OrgIAMPolicyAddedEvent {
|
|
|
|
return &OrgIAMPolicyAddedEvent{
|
|
BaseEvent: *base,
|
|
UserLoginMustBeDomain: userLoginMustBeDomain,
|
|
}
|
|
}
|
|
|
|
func OrgIAMPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &OrgIAMPolicyAddedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "POLIC-TvSmA", "unable to unmarshal policy")
|
|
}
|
|
|
|
return e, nil
|
|
}
|
|
|
|
type OrgIAMPolicyChangedEvent struct {
|
|
eventstore.BaseEvent `json:"-"`
|
|
|
|
UserLoginMustBeDomain *bool `json:"userLoginMustBeDomain,omitempty"`
|
|
}
|
|
|
|
func (e *OrgIAMPolicyChangedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func NewOrgIAMPolicyChangedEvent(
|
|
base *eventstore.BaseEvent,
|
|
) *OrgIAMPolicyChangedEvent {
|
|
return &OrgIAMPolicyChangedEvent{
|
|
BaseEvent: *base,
|
|
}
|
|
}
|
|
|
|
func OrgIAMPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &OrgIAMPolicyChangedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "POLIC-0Pl9d", "unable to unmarshal policy")
|
|
}
|
|
|
|
return e, nil
|
|
}
|