mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-01 13:32:41 +00:00
start implementing new eventstore on iam
This commit is contained in:
@@ -2,8 +2,11 @@ package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -26,6 +29,20 @@ type LabelPolicyReadModel struct {
|
||||
SecondaryColor string
|
||||
}
|
||||
|
||||
func (rm *LabelPolicyReadModel) Reduce() error {
|
||||
for _, event := range rm.Events {
|
||||
switch e := event.(type) {
|
||||
case *LabelPolicyAddedEvent:
|
||||
rm.PrimaryColor = e.PrimaryColor
|
||||
rm.SecondaryColor = e.SecondaryColor
|
||||
case *LabelPolicyChangedEvent:
|
||||
rm.PrimaryColor = e.PrimaryColor
|
||||
rm.SecondaryColor = e.SecondaryColor
|
||||
}
|
||||
}
|
||||
return rm.ReadModel.Reduce()
|
||||
}
|
||||
|
||||
type LabelPolicyAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
@@ -57,6 +74,19 @@ func NewLabelPolicyAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
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:"-"`
|
||||
|
||||
@@ -94,6 +124,19 @@ func NewLabelPolicyChangedEvent(
|
||||
return e
|
||||
}
|
||||
|
||||
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:"-"`
|
||||
}
|
||||
@@ -114,3 +157,9 @@ func NewLabelPolicyRemovedEvent(ctx context.Context) *LabelPolicyRemovedEvent {
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LabelPolicyRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
return &LabelPolicyRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -28,6 +31,22 @@ type LoginPolicyReadModel struct {
|
||||
AllowExternalIDP bool
|
||||
}
|
||||
|
||||
func (rm *LoginPolicyReadModel) Reduce() error {
|
||||
for _, event := range rm.Events {
|
||||
switch e := event.(type) {
|
||||
case *LoginPolicyAddedEvent:
|
||||
rm.AllowUserNamePassword = e.AllowUserNamePassword
|
||||
rm.AllowExternalIDP = e.AllowExternalIDP
|
||||
rm.AllowRegister = e.AllowRegister
|
||||
case *LoginPolicyChangedEvent:
|
||||
rm.AllowUserNamePassword = e.AllowUserNamePassword
|
||||
rm.AllowExternalIDP = e.AllowExternalIDP
|
||||
rm.AllowRegister = e.AllowRegister
|
||||
}
|
||||
}
|
||||
return rm.ReadModel.Reduce()
|
||||
}
|
||||
|
||||
type LoginPolicyAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
@@ -63,6 +82,19 @@ func NewLoginPolicyAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func LoginPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &LoginPolicyAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-nWndT", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type LoginPolicyChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
@@ -105,6 +137,19 @@ func NewLoginPolicyChangedEvent(
|
||||
return e
|
||||
}
|
||||
|
||||
func LoginPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &LoginPolicyChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-ehssl", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type LoginPolicyRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
@@ -125,3 +170,9 @@ func NewLoginPolicyRemovedEvent(ctx context.Context) *LoginPolicyRemovedEvent {
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func LoginPolicyRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
return &LoginPolicyRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -22,6 +25,16 @@ type OrgIAMPolicyReadModel struct {
|
||||
UserLoginMustBeDomain bool
|
||||
}
|
||||
|
||||
func (rm *OrgIAMPolicyReadModel) Reduce() error {
|
||||
for _, event := range rm.Events {
|
||||
switch e := event.(type) {
|
||||
case *OrgIAMPolicyAddedEvent:
|
||||
rm.UserLoginMustBeDomain = e.UserLoginMustBeDomain
|
||||
}
|
||||
}
|
||||
return rm.ReadModel.Reduce()
|
||||
}
|
||||
|
||||
type OrgIAMPolicyAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
@@ -49,3 +62,16 @@ func NewOrgIAMPolicyAddedEvent(
|
||||
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
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -15,22 +18,36 @@ const (
|
||||
type PasswordAgePolicyAggregate struct {
|
||||
eventstore.Aggregate
|
||||
|
||||
ExpireWarnDays int
|
||||
MaxAgeDays int
|
||||
ExpireWarnDays uint16
|
||||
MaxAgeDays uint16
|
||||
}
|
||||
|
||||
type PasswordAgePolicyReadModel struct {
|
||||
eventstore.ReadModel
|
||||
|
||||
ExpireWarnDays int
|
||||
MaxAgeDays int
|
||||
ExpireWarnDays uint16
|
||||
MaxAgeDays uint16
|
||||
}
|
||||
|
||||
func (rm *PasswordAgePolicyReadModel) Reduce() error {
|
||||
for _, event := range rm.Events {
|
||||
switch e := event.(type) {
|
||||
case *PasswordAgePolicyAddedEvent:
|
||||
rm.ExpireWarnDays = e.ExpireWarnDays
|
||||
rm.MaxAgeDays = e.MaxAgeDays
|
||||
case *PasswordAgePolicyChangedEvent:
|
||||
rm.ExpireWarnDays = e.ExpireWarnDays
|
||||
rm.MaxAgeDays = e.MaxAgeDays
|
||||
}
|
||||
}
|
||||
return rm.ReadModel.Reduce()
|
||||
}
|
||||
|
||||
type PasswordAgePolicyAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ExpireWarnDays int `json:"expireWarnDays"`
|
||||
MaxAgeDays int `json:"maxAgeDays"`
|
||||
ExpireWarnDays uint16 `json:"expireWarnDays"`
|
||||
MaxAgeDays uint16 `json:"maxAgeDays"`
|
||||
}
|
||||
|
||||
func (e *PasswordAgePolicyAddedEvent) CheckPrevious() bool {
|
||||
@@ -44,7 +61,7 @@ func (e *PasswordAgePolicyAddedEvent) Data() interface{} {
|
||||
func NewPasswordAgePolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
expireWarnDays,
|
||||
maxAgeDays int,
|
||||
maxAgeDays uint16,
|
||||
) *PasswordAgePolicyAddedEvent {
|
||||
|
||||
return &PasswordAgePolicyAddedEvent{
|
||||
@@ -57,11 +74,24 @@ func NewPasswordAgePolicyAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordAgePolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &PasswordAgePolicyAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-T3mGp", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type PasswordAgePolicyChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
ExpireWarnDays int `json:"expireWarnDays,omitempty"`
|
||||
MaxAgeDays int `json:"maxAgeDays,omitempty"`
|
||||
ExpireWarnDays uint16 `json:"expireWarnDays,omitempty"`
|
||||
MaxAgeDays uint16 `json:"maxAgeDays,omitempty"`
|
||||
}
|
||||
|
||||
func (e *PasswordAgePolicyChangedEvent) CheckPrevious() bool {
|
||||
@@ -95,6 +125,19 @@ func NewPasswordAgePolicyChangedEvent(
|
||||
return e
|
||||
}
|
||||
|
||||
func PasswordAgePolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &PasswordAgePolicyChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-PqaVq", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type PasswordAgePolicyRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
@@ -120,3 +163,16 @@ func NewPasswordAgePolicyRemovedEvent(
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordAgePolicyRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &PasswordAgePolicyRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-02878", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -15,7 +18,7 @@ const (
|
||||
type PasswordComplexityPolicyAggregate struct {
|
||||
eventstore.Aggregate
|
||||
|
||||
MinLength int
|
||||
MinLength uint8
|
||||
HasLowercase bool
|
||||
HasUpperCase bool
|
||||
HasNumber bool
|
||||
@@ -25,21 +28,41 @@ type PasswordComplexityPolicyAggregate struct {
|
||||
type PasswordComplexityPolicyReadModel struct {
|
||||
eventstore.ReadModel
|
||||
|
||||
MinLength int
|
||||
MinLength uint8
|
||||
HasLowercase bool
|
||||
HasUpperCase bool
|
||||
HasNumber bool
|
||||
HasSymbol bool
|
||||
}
|
||||
|
||||
func (rm *PasswordComplexityPolicyReadModel) Reduce() error {
|
||||
for _, event := range rm.Events {
|
||||
switch e := event.(type) {
|
||||
case *PasswordComplexityPolicyAddedEvent:
|
||||
rm.MinLength = e.MinLength
|
||||
rm.HasLowercase = e.HasLowercase
|
||||
rm.HasUpperCase = e.HasUpperCase
|
||||
rm.HasNumber = e.HasNumber
|
||||
rm.HasSymbol = e.HasSymbol
|
||||
case *PasswordComplexityPolicyChangedEvent:
|
||||
rm.MinLength = e.MinLength
|
||||
rm.HasLowercase = e.HasLowercase
|
||||
rm.HasUpperCase = e.HasUpperCase
|
||||
rm.HasNumber = e.HasNumber
|
||||
rm.HasSymbol = e.HasSymbol
|
||||
}
|
||||
}
|
||||
return rm.ReadModel.Reduce()
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicyAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
MinLength int `json:"minLength"`
|
||||
HasLowercase bool `json:"hasLowercase"`
|
||||
HasUpperCase bool `json:"hasUppercase"`
|
||||
HasNumber bool `json:"hasNumber"`
|
||||
HasSymbol bool `json:"hasSymbol"`
|
||||
MinLength uint8 `json:"minLength"`
|
||||
HasLowercase bool `json:"hasLowercase"`
|
||||
HasUpperCase bool `json:"hasUppercase"`
|
||||
HasNumber bool `json:"hasNumber"`
|
||||
HasSymbol bool `json:"hasSymbol"`
|
||||
}
|
||||
|
||||
func (e *PasswordComplexityPolicyAddedEvent) CheckPrevious() bool {
|
||||
@@ -56,7 +79,7 @@ func NewPasswordComplexityPolicyAddedEvent(
|
||||
hasUpperCase,
|
||||
hasNumber,
|
||||
hasSymbol bool,
|
||||
minLength int,
|
||||
minLength uint8,
|
||||
) *PasswordComplexityPolicyAddedEvent {
|
||||
|
||||
return &PasswordComplexityPolicyAddedEvent{
|
||||
@@ -72,14 +95,27 @@ func NewPasswordComplexityPolicyAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordComplexityPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &PasswordComplexityPolicyAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-wYxlM", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicyChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
MinLength int `json:"minLength"`
|
||||
HasLowercase bool `json:"hasLowercase"`
|
||||
HasUpperCase bool `json:"hasUppercase"`
|
||||
HasNumber bool `json:"hasNumber"`
|
||||
HasSymbol bool `json:"hasSymbol"`
|
||||
MinLength uint8 `json:"minLength"`
|
||||
HasLowercase bool `json:"hasLowercase"`
|
||||
HasUpperCase bool `json:"hasUppercase"`
|
||||
HasNumber bool `json:"hasNumber"`
|
||||
HasSymbol bool `json:"hasSymbol"`
|
||||
}
|
||||
|
||||
func (e *PasswordComplexityPolicyChangedEvent) CheckPrevious() bool {
|
||||
@@ -122,6 +158,19 @@ func NewPasswordComplexityPolicyChangedEvent(
|
||||
return e
|
||||
}
|
||||
|
||||
func PasswordComplexityPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &PasswordComplexityPolicyChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-zBGB0", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type PasswordComplexityPolicyRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
@@ -145,3 +194,9 @@ func NewPasswordComplexityPolicyRemovedEvent(
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordComplexityPolicyRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
return &PasswordComplexityPolicyRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -2,8 +2,11 @@ package policy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -15,22 +18,36 @@ const (
|
||||
type PasswordLockoutPolicyAggregate struct {
|
||||
eventstore.Aggregate
|
||||
|
||||
MaxAttempts int
|
||||
MaxAttempts uint8
|
||||
ShowLockOutFailures bool
|
||||
}
|
||||
|
||||
type PasswordLockoutPolicyReadModel struct {
|
||||
eventstore.ReadModel
|
||||
|
||||
MaxAttempts int
|
||||
MaxAttempts uint8
|
||||
ShowLockOutFailures bool
|
||||
}
|
||||
|
||||
func (rm *PasswordLockoutPolicyReadModel) Reduce() error {
|
||||
for _, event := range rm.Events {
|
||||
switch e := event.(type) {
|
||||
case *PasswordLockoutPolicyAddedEvent:
|
||||
rm.MaxAttempts = e.MaxAttempts
|
||||
rm.ShowLockOutFailures = e.ShowLockOutFailures
|
||||
case *PasswordLockoutPolicyChangedEvent:
|
||||
rm.MaxAttempts = e.MaxAttempts
|
||||
rm.ShowLockOutFailures = e.ShowLockOutFailures
|
||||
}
|
||||
}
|
||||
return rm.ReadModel.Reduce()
|
||||
}
|
||||
|
||||
type PasswordLockoutPolicyAddedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
MaxAttempts int `json:"maxAttempts"`
|
||||
ShowLockOutFailures bool `json:"showLockOutFailures"`
|
||||
MaxAttempts uint8 `json:"maxAttempts"`
|
||||
ShowLockOutFailures bool `json:"showLockOutFailures"`
|
||||
}
|
||||
|
||||
func (e *PasswordLockoutPolicyAddedEvent) CheckPrevious() bool {
|
||||
@@ -43,7 +60,7 @@ func (e *PasswordLockoutPolicyAddedEvent) Data() interface{} {
|
||||
|
||||
func NewPasswordLockoutPolicyAddedEvent(
|
||||
ctx context.Context,
|
||||
maxAttempts int,
|
||||
maxAttempts uint8,
|
||||
showLockOutFailures bool,
|
||||
) *PasswordLockoutPolicyAddedEvent {
|
||||
|
||||
@@ -57,11 +74,24 @@ func NewPasswordLockoutPolicyAddedEvent(
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordLockoutPolicyAddedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &PasswordLockoutPolicyAddedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-8XiVd", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type PasswordLockoutPolicyChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
MaxAttempts int `json:"maxAttempts,omitempty"`
|
||||
ShowLockOutFailures bool `json:"showLockOutFailures,omitempty"`
|
||||
MaxAttempts uint8 `json:"maxAttempts,omitempty"`
|
||||
ShowLockOutFailures bool `json:"showLockOutFailures,omitempty"`
|
||||
}
|
||||
|
||||
func (e *PasswordLockoutPolicyChangedEvent) CheckPrevious() bool {
|
||||
@@ -95,6 +125,19 @@ func NewPasswordLockoutPolicyChangedEvent(
|
||||
return e
|
||||
}
|
||||
|
||||
func PasswordLockoutPolicyChangedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
e := &PasswordLockoutPolicyChangedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}
|
||||
|
||||
err := json.Unmarshal(event.Data, e)
|
||||
if err != nil {
|
||||
return nil, errors.ThrowInternal(err, "POLIC-lWGRc", "unable to unmarshal policy")
|
||||
}
|
||||
|
||||
return e, nil
|
||||
}
|
||||
|
||||
type PasswordLockoutPolicyRemovedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
}
|
||||
@@ -118,3 +161,9 @@ func NewPasswordLockoutPolicyRemovedEvent(
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
func PasswordLockoutPolicyRemovedEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
||||
return &PasswordLockoutPolicyRemovedEvent{
|
||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user