mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-05 22:52:46 +00:00
iam events
This commit is contained in:
parent
f4bd5ddcbc
commit
f7f810caa5
@ -1,8 +1,10 @@
|
|||||||
package eventstore
|
package eventstore
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/api/authz"
|
||||||
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
"github.com/caos/zitadel/internal/eventstore/v2/repository"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -75,4 +77,10 @@ func BaseEventFromRepo(event *repository.Event) *BaseEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewBaseEvent()
|
func NewBaseEventForPush(ctx context.Context, service string, typ EventType) *BaseEvent {
|
||||||
|
return &BaseEvent{
|
||||||
|
User: authz.GetCtxData(ctx).UserID,
|
||||||
|
Service: service,
|
||||||
|
EventType: typ,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -19,7 +19,7 @@ type Eventstore struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type eventTypeInterceptors struct {
|
type eventTypeInterceptors struct {
|
||||||
eventMapper func(*repository.Event) (Event, error)
|
eventMapper func(*repository.Event) (EventReader, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewEventstore(repo repository.Repository) *Eventstore {
|
func NewEventstore(repo repository.Repository) *Eventstore {
|
||||||
@ -166,7 +166,7 @@ func (es *Eventstore) LatestSequence(ctx context.Context, queryFactory *SearchQu
|
|||||||
}
|
}
|
||||||
|
|
||||||
//RegisterFilterEventMapper registers a function for mapping an eventstore event to an event
|
//RegisterFilterEventMapper registers a function for mapping an eventstore event to an event
|
||||||
func (es *Eventstore) RegisterFilterEventMapper(eventType EventType, mapper func(*repository.Event) (Event, error)) *Eventstore {
|
func (es *Eventstore) RegisterFilterEventMapper(eventType EventType, mapper func(*repository.Event) (EventReader, error)) *Eventstore {
|
||||||
if mapper == nil || eventType == "" {
|
if mapper == nil || eventType == "" {
|
||||||
return es
|
return es
|
||||||
}
|
}
|
||||||
|
@ -55,11 +55,11 @@ func newTestEvent(description string, data func() interface{}, checkPrevious boo
|
|||||||
description: description,
|
description: description,
|
||||||
data: data,
|
data: data,
|
||||||
shouldCheckPrevious: checkPrevious,
|
shouldCheckPrevious: checkPrevious,
|
||||||
BaseEvent: BaseEvent{
|
BaseEvent: *NewBaseEventForPush(
|
||||||
User: "editorUser",
|
"editorUser",
|
||||||
Service: "editorService",
|
"editorService",
|
||||||
EventType: "test.event",
|
"test.event",
|
||||||
},
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ func (e *testEvent) Data() interface{} {
|
|||||||
return e.data()
|
return e.data()
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFilterMapper(event *repository.Event) (Event, error) {
|
func testFilterMapper(event *repository.Event) (EventReader, error) {
|
||||||
if event == nil {
|
if event == nil {
|
||||||
return newTestEvent("hodor", nil, false), nil
|
return newTestEvent("hodor", nil, false), nil
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ func Test_eventstore_RegisterFilterEventMapper(t *testing.T) {
|
|||||||
}
|
}
|
||||||
type args struct {
|
type args struct {
|
||||||
eventType EventType
|
eventType EventType
|
||||||
mapper func(*repository.Event) (Event, error)
|
mapper func(*repository.Event) (EventReader, error)
|
||||||
}
|
}
|
||||||
type res struct {
|
type res struct {
|
||||||
event Event
|
event Event
|
||||||
@ -158,7 +158,7 @@ func Test_eventstore_RegisterFilterEventMapper(t *testing.T) {
|
|||||||
fields: fields{
|
fields: fields{
|
||||||
eventMapper: map[EventType]eventTypeInterceptors{
|
eventMapper: map[EventType]eventTypeInterceptors{
|
||||||
"event.type": {
|
"event.type": {
|
||||||
eventMapper: func(*repository.Event) (Event, error) {
|
eventMapper: func(*repository.Event) (EventReader, error) {
|
||||||
return nil, errors.ThrowUnimplemented(nil, "V2-1qPvn", "unimplemented")
|
return nil, errors.ThrowUnimplemented(nil, "V2-1qPvn", "unimplemented")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -627,7 +627,7 @@ func TestEventstore_Push(t *testing.T) {
|
|||||||
}
|
}
|
||||||
type fields struct {
|
type fields struct {
|
||||||
repo *testRepo
|
repo *testRepo
|
||||||
eventMapper map[EventType]func(*repository.Event) (Event, error)
|
eventMapper map[EventType]func(*repository.Event) (EventReader, error)
|
||||||
}
|
}
|
||||||
type res struct {
|
type res struct {
|
||||||
wantErr bool
|
wantErr bool
|
||||||
@ -672,8 +672,8 @@ func TestEventstore_Push(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -730,8 +730,8 @@ func TestEventstore_Push(t *testing.T) {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -817,8 +817,8 @@ func TestEventstore_Push(t *testing.T) {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -911,7 +911,7 @@ func TestEventstore_FilterEvents(t *testing.T) {
|
|||||||
}
|
}
|
||||||
type fields struct {
|
type fields struct {
|
||||||
repo *testRepo
|
repo *testRepo
|
||||||
eventMapper map[EventType]func(*repository.Event) (Event, error)
|
eventMapper map[EventType]func(*repository.Event) (EventReader, error)
|
||||||
}
|
}
|
||||||
type res struct {
|
type res struct {
|
||||||
wantErr bool
|
wantErr bool
|
||||||
@ -944,8 +944,8 @@ func TestEventstore_FilterEvents(t *testing.T) {
|
|||||||
events: []*repository.Event{},
|
events: []*repository.Event{},
|
||||||
t: t,
|
t: t,
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -967,8 +967,8 @@ func TestEventstore_FilterEvents(t *testing.T) {
|
|||||||
t: t,
|
t: t,
|
||||||
err: errors.ThrowInternal(nil, "V2-RfkBa", "test err"),
|
err: errors.ThrowInternal(nil, "V2-RfkBa", "test err"),
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -995,8 +995,8 @@ func TestEventstore_FilterEvents(t *testing.T) {
|
|||||||
},
|
},
|
||||||
t: t,
|
t: t,
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1126,7 +1126,7 @@ func TestEventstore_LatestSequence(t *testing.T) {
|
|||||||
|
|
||||||
type testReducer struct {
|
type testReducer struct {
|
||||||
t *testing.T
|
t *testing.T
|
||||||
events []Event
|
events []EventReader
|
||||||
expectedLength int
|
expectedLength int
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
@ -1142,7 +1142,7 @@ func (r *testReducer) Reduce() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *testReducer) AppendEvents(e ...Event) error {
|
func (r *testReducer) AppendEvents(e ...EventReader) error {
|
||||||
if r.err != nil {
|
if r.err != nil {
|
||||||
return r.err
|
return r.err
|
||||||
}
|
}
|
||||||
@ -1157,7 +1157,7 @@ func TestEventstore_FilterToReducer(t *testing.T) {
|
|||||||
}
|
}
|
||||||
type fields struct {
|
type fields struct {
|
||||||
repo *testRepo
|
repo *testRepo
|
||||||
eventMapper map[EventType]func(*repository.Event) (Event, error)
|
eventMapper map[EventType]func(*repository.Event) (EventReader, error)
|
||||||
}
|
}
|
||||||
type res struct {
|
type res struct {
|
||||||
wantErr bool
|
wantErr bool
|
||||||
@ -1194,8 +1194,8 @@ func TestEventstore_FilterToReducer(t *testing.T) {
|
|||||||
events: []*repository.Event{},
|
events: []*repository.Event{},
|
||||||
t: t,
|
t: t,
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1221,8 +1221,8 @@ func TestEventstore_FilterToReducer(t *testing.T) {
|
|||||||
t: t,
|
t: t,
|
||||||
err: errors.ThrowInternal(nil, "V2-RfkBa", "test err"),
|
err: errors.ThrowInternal(nil, "V2-RfkBa", "test err"),
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1253,8 +1253,8 @@ func TestEventstore_FilterToReducer(t *testing.T) {
|
|||||||
},
|
},
|
||||||
t: t,
|
t: t,
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1282,8 +1282,8 @@ func TestEventstore_FilterToReducer(t *testing.T) {
|
|||||||
},
|
},
|
||||||
t: t,
|
t: t,
|
||||||
},
|
},
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(e *repository.Event) (Event, error) {
|
"test.event": func(e *repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1371,13 +1371,13 @@ func compareEvents(t *testing.T, want, got *repository.Event) {
|
|||||||
|
|
||||||
func TestEventstore_mapEvents(t *testing.T) {
|
func TestEventstore_mapEvents(t *testing.T) {
|
||||||
type fields struct {
|
type fields struct {
|
||||||
eventMapper map[EventType]func(*repository.Event) (Event, error)
|
eventMapper map[EventType]func(*repository.Event) (EventReader, error)
|
||||||
}
|
}
|
||||||
type args struct {
|
type args struct {
|
||||||
events []*repository.Event
|
events []*repository.Event
|
||||||
}
|
}
|
||||||
type res struct {
|
type res struct {
|
||||||
events []Event
|
events []EventReader
|
||||||
wantErr bool
|
wantErr bool
|
||||||
}
|
}
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
@ -1396,7 +1396,7 @@ func TestEventstore_mapEvents(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
fields: fields{
|
fields: fields{
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){},
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){},
|
||||||
},
|
},
|
||||||
res: res{
|
res: res{
|
||||||
wantErr: true,
|
wantErr: true,
|
||||||
@ -1412,8 +1412,8 @@ func TestEventstore_mapEvents(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
fields: fields{
|
fields: fields{
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(*repository.Event) (Event, error) {
|
"test.event": func(*repository.Event) (EventReader, error) {
|
||||||
return nil, errors.ThrowInternal(nil, "V2-8FbQk", "test err")
|
return nil, errors.ThrowInternal(nil, "V2-8FbQk", "test err")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -1432,14 +1432,14 @@ func TestEventstore_mapEvents(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
fields: fields{
|
fields: fields{
|
||||||
eventMapper: map[EventType]func(*repository.Event) (Event, error){
|
eventMapper: map[EventType]func(*repository.Event) (EventReader, error){
|
||||||
"test.event": func(*repository.Event) (Event, error) {
|
"test.event": func(*repository.Event) (EventReader, error) {
|
||||||
return &testEvent{}, nil
|
return &testEvent{}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
res: res{
|
res: res{
|
||||||
events: []Event{
|
events: []EventReader{
|
||||||
&testEvent{},
|
&testEvent{},
|
||||||
},
|
},
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
|
@ -92,8 +92,8 @@ func NewUserAddedEvent(firstName string) *UserAddedEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserAddedEventMapper() (eventstore.EventType, func(*repository.Event) (eventstore.Event, error)) {
|
func UserAddedEventMapper() (eventstore.EventType, func(*repository.Event) (eventstore.EventReader, error)) {
|
||||||
return "user.added", func(event *repository.Event) (eventstore.Event, error) {
|
return "user.added", func(event *repository.Event) (eventstore.EventReader, error) {
|
||||||
e := &UserAddedEvent{
|
e := &UserAddedEvent{
|
||||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||||
}
|
}
|
||||||
@ -134,8 +134,8 @@ func NewUserFirstNameChangedEvent(firstName string) *UserFirstNameChangedEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserFirstNameChangedMapper() (eventstore.EventType, func(*repository.Event) (eventstore.Event, error)) {
|
func UserFirstNameChangedMapper() (eventstore.EventType, func(*repository.Event) (eventstore.EventReader, error)) {
|
||||||
return "user.firstName.changed", func(event *repository.Event) (eventstore.Event, error) {
|
return "user.firstName.changed", func(event *repository.Event) (eventstore.EventReader, error) {
|
||||||
e := &UserFirstNameChangedEvent{
|
e := &UserFirstNameChangedEvent{
|
||||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||||
}
|
}
|
||||||
@ -173,8 +173,8 @@ func NewUserPasswordCheckedEvent() *UserPasswordCheckedEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserPasswordCheckedMapper() (eventstore.EventType, func(*repository.Event) (eventstore.Event, error)) {
|
func UserPasswordCheckedMapper() (eventstore.EventType, func(*repository.Event) (eventstore.EventReader, error)) {
|
||||||
return "user.password.checked", func(event *repository.Event) (eventstore.Event, error) {
|
return "user.password.checked", func(event *repository.Event) (eventstore.EventReader, error) {
|
||||||
return &UserPasswordCheckedEvent{
|
return &UserPasswordCheckedEvent{
|
||||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||||
}, nil
|
}, nil
|
||||||
@ -207,8 +207,8 @@ func NewUserDeletedEvent() *UserDeletedEvent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func UserDeletedMapper() (eventstore.EventType, func(*repository.Event) (eventstore.Event, error)) {
|
func UserDeletedMapper() (eventstore.EventType, func(*repository.Event) (eventstore.EventReader, error)) {
|
||||||
return "user.deleted", func(event *repository.Event) (eventstore.Event, error) {
|
return "user.deleted", func(event *repository.Event) (eventstore.EventReader, error) {
|
||||||
return &UserDeletedEvent{
|
return &UserDeletedEvent{
|
||||||
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
||||||
}, nil
|
}, nil
|
||||||
@ -239,24 +239,24 @@ func NewUsersReadModel() *UsersReadModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rm *UsersReadModel) AppendEvents(events ...eventstore.Event) (err error) {
|
func (rm *UsersReadModel) AppendEvents(events ...eventstore.EventReader) (err error) {
|
||||||
rm.ReadModel.AppendEvents(events...)
|
rm.ReadModel.AppendEvents(events...)
|
||||||
for _, event := range events {
|
for _, event := range events {
|
||||||
switch e := event.(type) {
|
switch e := event.(type) {
|
||||||
case *UserAddedEvent:
|
case *UserAddedEvent:
|
||||||
//insert
|
//insert
|
||||||
user := NewUserReadModel(e.Base().AggregateID)
|
user := NewUserReadModel(e.AggregateID())
|
||||||
rm.Users = append(rm.Users, user)
|
rm.Users = append(rm.Users, user)
|
||||||
err = user.AppendEvents(e)
|
err = user.AppendEvents(e)
|
||||||
case *UserFirstNameChangedEvent, *UserPasswordCheckedEvent:
|
case *UserFirstNameChangedEvent, *UserPasswordCheckedEvent:
|
||||||
//update
|
//update
|
||||||
_, user := rm.userByID(e.Base().aggregateID)
|
_, user := rm.userByID(e.AggregateID())
|
||||||
if user == nil {
|
if user == nil {
|
||||||
return errors.New("user not found")
|
return errors.New("user not found")
|
||||||
}
|
}
|
||||||
err = user.AppendEvents(e)
|
err = user.AppendEvents(e)
|
||||||
case *UserDeletedEvent:
|
case *UserDeletedEvent:
|
||||||
idx, _ := rm.userByID(e.Base().AggregateID)
|
idx, _ := rm.userByID(e.AggregateID())
|
||||||
if idx < 0 {
|
if idx < 0 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -310,7 +310,7 @@ func NewUserReadModel(id string) *UserReadModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rm *UserReadModel) AppendEvents(events ...eventstore.Event) error {
|
func (rm *UserReadModel) AppendEvents(events ...eventstore.EventReader) error {
|
||||||
rm.ReadModel.AppendEvents(events...)
|
rm.ReadModel.AppendEvents(events...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -324,7 +324,7 @@ func (rm *UserReadModel) Reduce() error {
|
|||||||
rm.FirstName = e.FirstName
|
rm.FirstName = e.FirstName
|
||||||
case *UserPasswordCheckedEvent:
|
case *UserPasswordCheckedEvent:
|
||||||
rm.pwCheckCount++
|
rm.pwCheckCount++
|
||||||
rm.lastPasswordCheck = e.Base().CreationDate
|
rm.lastPasswordCheck = e.CreationDate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rm.ReadModel.Reduce()
|
rm.ReadModel.Reduce()
|
||||||
|
@ -5,23 +5,23 @@ import "time"
|
|||||||
func NewReadModel(id string) *ReadModel {
|
func NewReadModel(id string) *ReadModel {
|
||||||
return &ReadModel{
|
return &ReadModel{
|
||||||
ID: id,
|
ID: id,
|
||||||
Events: []Event{},
|
Events: []EventReader{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//ReadModel is the minimum representation of a View model.
|
//ReadModel is the minimum representation of a View model.
|
||||||
// it might be saved in a database or in memory
|
// it might be saved in a database or in memory
|
||||||
type ReadModel struct {
|
type ReadModel struct {
|
||||||
ProcessedSequence uint64 `json:"-"`
|
ProcessedSequence uint64 `json:"-"`
|
||||||
ID string `json:"-"`
|
ID string `json:"-"`
|
||||||
CreationDate time.Time `json:"-"`
|
CreationDate time.Time `json:"-"`
|
||||||
ChangeDate time.Time `json:"-"`
|
ChangeDate time.Time `json:"-"`
|
||||||
Events []Event `json:"-"`
|
Events []EventReader `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//AppendEvents adds all the events to the read model.
|
//AppendEvents adds all the events to the read model.
|
||||||
// The function doesn't compute the new state of the read model
|
// The function doesn't compute the new state of the read model
|
||||||
func (rm *ReadModel) AppendEvents(events ...Event) *ReadModel {
|
func (rm *ReadModel) AppendEvents(events ...EventReader) *ReadModel {
|
||||||
rm.Events = append(rm.Events, events...)
|
rm.Events = append(rm.Events, events...)
|
||||||
return rm
|
return rm
|
||||||
}
|
}
|
||||||
@ -33,13 +33,13 @@ func (rm *ReadModel) Reduce() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if rm.CreationDate.IsZero() {
|
if rm.CreationDate.IsZero() {
|
||||||
rm.CreationDate = rm.Events[0].Base().creationDate
|
rm.CreationDate = rm.Events[0].CreationDate()
|
||||||
}
|
}
|
||||||
rm.ChangeDate = rm.Events[len(rm.Events)-1].Base().creationDate
|
rm.ChangeDate = rm.Events[len(rm.Events)-1].CreationDate()
|
||||||
rm.ProcessedSequence = rm.Events[len(rm.Events)-1].Base().sequence
|
rm.ProcessedSequence = rm.Events[len(rm.Events)-1].Sequence()
|
||||||
// all events processed and not needed anymore
|
// all events processed and not needed anymore
|
||||||
rm.Events = nil
|
rm.Events = nil
|
||||||
rm.Events = []Event{}
|
rm.Events = []EventReader{}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ func (a *Aggregate) Reduce() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
a.PreviousSequence = a.Events[len(a.Events)-1].Base().sequence
|
a.PreviousSequence = a.Events[len(a.Events)-1].Sequence()
|
||||||
// all events processed and not needed anymore
|
// all events processed and not needed anymore
|
||||||
a.Events = nil
|
a.Events = nil
|
||||||
a.Events = []Event{}
|
a.Events = []Event{}
|
||||||
|
@ -5,32 +5,3 @@ import "github.com/caos/zitadel/internal/eventstore/v2"
|
|||||||
type Aggregate struct {
|
type Aggregate struct {
|
||||||
eventstore.Aggregate
|
eventstore.Aggregate
|
||||||
}
|
}
|
||||||
|
|
||||||
type Step int8
|
|
||||||
|
|
||||||
type SetupStepEvent struct {
|
|
||||||
eventstore.BaseEvent `json:"-"`
|
|
||||||
|
|
||||||
Step Step
|
|
||||||
//Done if the setup is started earlier
|
|
||||||
Done bool `json:"-"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *SetupStepEvent) CheckPrevious() bool {
|
|
||||||
return e.Type() == "iam.setup.started"
|
|
||||||
}
|
|
||||||
|
|
||||||
//Type implements event
|
|
||||||
func (e *SetupStepEvent) Type() eventstore.EventType {
|
|
||||||
if e.Done {
|
|
||||||
return "iam.setup.done"
|
|
||||||
}
|
|
||||||
return "iam.setup.started"
|
|
||||||
}
|
|
||||||
|
|
||||||
func (e *SetupStepEvent) Data() interface{} {
|
|
||||||
return e
|
|
||||||
}
|
|
||||||
|
|
||||||
type MemberAddedEvent struct {
|
|
||||||
}
|
|
||||||
|
36
internal/v2/repository/iam/event_iam_added.go
Normal file
36
internal/v2/repository/iam/event_iam_added.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package iam
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
GlobalOrgSetEventType eventstore.EventType = "iam.global.org.set"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GlobalOrgSetEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
OrgID string `json:"globalOrgId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *GlobalOrgSetEvent) CheckPrevious() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *GlobalOrgSetEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewGlobalOrgSetEventEvent(ctx context.Context, service, orgID string) *GlobalOrgSetEvent {
|
||||||
|
return &GlobalOrgSetEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
GlobalOrgSetEventType,
|
||||||
|
),
|
||||||
|
OrgID: orgID,
|
||||||
|
}
|
||||||
|
}
|
36
internal/v2/repository/iam/event_iam_project_set.go
Normal file
36
internal/v2/repository/iam/event_iam_project_set.go
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package iam
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
IAMProjectSetEventType eventstore.EventType = "iam.project.iam.set"
|
||||||
|
)
|
||||||
|
|
||||||
|
type IAMProjectSetEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
ProjectID string `json:"iamProjectId"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *IAMProjectSetEvent) CheckPrevious() bool {
|
||||||
|
return e.Type() == SetupStartedEventType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *IAMProjectSetEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewIAMProjectSetEvent(ctx context.Context, service, projectID string) *IAMProjectSetEvent {
|
||||||
|
return &IAMProjectSetEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
SetupDoneEventType,
|
||||||
|
),
|
||||||
|
ProjectID: projectID,
|
||||||
|
}
|
||||||
|
}
|
48
internal/v2/repository/iam/events_step.go
Normal file
48
internal/v2/repository/iam/events_step.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package iam
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
SetupDoneEventType eventstore.EventType = "iam.setup.done"
|
||||||
|
SetupStartedEventType eventstore.EventType = "iam.setup.started"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Step int8
|
||||||
|
|
||||||
|
type SetupStepEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
Step Step `json:"Step"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *SetupStepEvent) CheckPrevious() bool {
|
||||||
|
return e.Type() == SetupStartedEventType
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *SetupStepEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSetupStepDoneEvent(ctx context.Context, service string) *SetupStepEvent {
|
||||||
|
return &SetupStepEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
SetupDoneEventType,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewSetupStepStartedEvent(ctx context.Context, service string) *SetupStepEvent {
|
||||||
|
return &SetupStepEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
SetupStartedEventType,
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
@ -6,14 +6,6 @@ import (
|
|||||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewMemberAddedEvent(ctx context.Context, userID string, roles ...string) *MemberAddedEvent {
|
|
||||||
return &MemberAddedEvent{
|
|
||||||
BaseEvent: eventstore.BaseEvent{},
|
|
||||||
Roles: roles,
|
|
||||||
UserID: userID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type MemberAddedEvent struct {
|
type MemberAddedEvent struct {
|
||||||
eventstore.BaseEvent `json:"-"`
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
@ -28,3 +20,15 @@ func (e *MemberAddedEvent) CheckPrevious() bool {
|
|||||||
func (e *MemberAddedEvent) Data() interface{} {
|
func (e *MemberAddedEvent) Data() interface{} {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewMemberAddedEvent(ctx context.Context, eventType eventstore.EventType, service, userID string, roles ...string) *MemberAddedEvent {
|
||||||
|
return &MemberAddedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
eventType,
|
||||||
|
),
|
||||||
|
Roles: roles,
|
||||||
|
UserID: userID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package member
|
package member
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,3 +19,14 @@ func (e *MemberRemovedEvent) CheckPrevious() bool {
|
|||||||
func (e *MemberRemovedEvent) Data() interface{} {
|
func (e *MemberRemovedEvent) Data() interface{} {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func NewMemberRemovedEvent(ctx context.Context, eventType eventstore.EventType, service, userID string) *MemberRemovedEvent {
|
||||||
|
return &MemberRemovedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
eventType,
|
||||||
|
),
|
||||||
|
UserID: userID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
44
internal/v2/repository/policy/events_label.go
Normal file
44
internal/v2/repository/policy/events_label.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package policy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
LabelPolicyAddedEventType = "policy.label.added"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LabelPolicyAddedEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
PrimaryColor string `json:"primaryColor"`
|
||||||
|
SecondaryColor string `json:"secondaryColor"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *LabelPolicyAddedEvent) CheckPrevious() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *LabelPolicyAddedEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLabelPolicyAddedEvent(
|
||||||
|
ctx context.Context,
|
||||||
|
service string,
|
||||||
|
primaryColor,
|
||||||
|
secondaryColor string,
|
||||||
|
) *LabelPolicyAddedEvent {
|
||||||
|
|
||||||
|
return &LabelPolicyAddedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
LabelPolicyAddedEventType,
|
||||||
|
),
|
||||||
|
PrimaryColor: primaryColor,
|
||||||
|
SecondaryColor: secondaryColor,
|
||||||
|
}
|
||||||
|
}
|
48
internal/v2/repository/policy/events_login.go
Normal file
48
internal/v2/repository/policy/events_login.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package policy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
LoginPolicyAddedEventType = "policy.login.added"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LoginPolicyAddedEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
AllowUserNamePassword bool `json:"allowUsernamePassword"`
|
||||||
|
AllowRegister bool `json:"allowRegister"`
|
||||||
|
AllowExternalIDP bool `json:"allowExternalIdp"`
|
||||||
|
// TODO: IDPProviders
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *LoginPolicyAddedEvent) CheckPrevious() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *LoginPolicyAddedEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLoginPolicyAddedEvent(
|
||||||
|
ctx context.Context,
|
||||||
|
service string,
|
||||||
|
allowUserNamePassword,
|
||||||
|
allowRegister,
|
||||||
|
allowExternalIDP bool,
|
||||||
|
) *LoginPolicyAddedEvent {
|
||||||
|
|
||||||
|
return &LoginPolicyAddedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
LoginPolicyAddedEventType,
|
||||||
|
),
|
||||||
|
AllowExternalIDP: allowExternalIDP,
|
||||||
|
AllowRegister: allowRegister,
|
||||||
|
AllowUserNamePassword: allowUserNamePassword,
|
||||||
|
}
|
||||||
|
}
|
41
internal/v2/repository/policy/events_org_iam.go
Normal file
41
internal/v2/repository/policy/events_org_iam.go
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package policy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
OrgIAMPolicyAddedEventType = "policy.org.iam.added"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OrgIAMPolicyAddedEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
UserLoginMustBeDomain bool `json:"allowUsernamePassword"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *OrgIAMPolicyAddedEvent) CheckPrevious() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *OrgIAMPolicyAddedEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOrgIAMPolicyAddedEvent(
|
||||||
|
ctx context.Context,
|
||||||
|
service string,
|
||||||
|
userLoginMustBeDomain bool,
|
||||||
|
) *OrgIAMPolicyAddedEvent {
|
||||||
|
|
||||||
|
return &OrgIAMPolicyAddedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
OrgIAMPolicyAddedEventType,
|
||||||
|
),
|
||||||
|
UserLoginMustBeDomain: userLoginMustBeDomain,
|
||||||
|
}
|
||||||
|
}
|
43
internal/v2/repository/policy/events_password_age.go
Normal file
43
internal/v2/repository/policy/events_password_age.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package policy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PasswordAgePolicyAddedEventType = "policy.password.age.added"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PasswordAgePolicyAddedEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
ExpireWarnDays int `json:"expireWarnDays"`
|
||||||
|
MaxAgeDays int `json:"maxAgeDays"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PasswordAgePolicyAddedEvent) CheckPrevious() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PasswordAgePolicyAddedEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPasswordAgePolicyAddedEvent(
|
||||||
|
ctx context.Context,
|
||||||
|
service string,
|
||||||
|
expireWarnDays,
|
||||||
|
maxAgeDays int,
|
||||||
|
) *PasswordAgePolicyAddedEvent {
|
||||||
|
return &PasswordAgePolicyAddedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
PasswordAgePolicyAddedEventType,
|
||||||
|
),
|
||||||
|
ExpireWarnDays: expireWarnDays,
|
||||||
|
MaxAgeDays: maxAgeDays,
|
||||||
|
}
|
||||||
|
}
|
53
internal/v2/repository/policy/events_password_complexity.go
Normal file
53
internal/v2/repository/policy/events_password_complexity.go
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package policy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PasswordComplexityPolicyAddedEventType = "policy.password.complexity.added"
|
||||||
|
)
|
||||||
|
|
||||||
|
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"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PasswordComplexityPolicyAddedEvent) CheckPrevious() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PasswordComplexityPolicyAddedEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPasswordComplexityPolicyAddedEvent(
|
||||||
|
ctx context.Context,
|
||||||
|
service string,
|
||||||
|
hasLowerCase,
|
||||||
|
hasUpperCase,
|
||||||
|
hasNumber,
|
||||||
|
hasSymbol bool,
|
||||||
|
minLength int,
|
||||||
|
) *PasswordComplexityPolicyAddedEvent {
|
||||||
|
|
||||||
|
return &PasswordComplexityPolicyAddedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
PasswordComplexityPolicyAddedEventType,
|
||||||
|
),
|
||||||
|
HasLowercase: hasLowerCase,
|
||||||
|
HasNumber: hasNumber,
|
||||||
|
HasSymbol: hasSymbol,
|
||||||
|
HasUpperCase: hasUpperCase,
|
||||||
|
MinLength: minLength,
|
||||||
|
}
|
||||||
|
}
|
44
internal/v2/repository/policy/events_password_lockout.go
Normal file
44
internal/v2/repository/policy/events_password_lockout.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package policy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
PasswordLockoutPolicyAddedEventType = "policy.password.lockout.added"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PasswordLockoutPolicyAddedEvent struct {
|
||||||
|
eventstore.BaseEvent `json:"-"`
|
||||||
|
|
||||||
|
MaxAttempts int `json:"maxAttempts"`
|
||||||
|
ShowLockOutFailures bool `json:"showLockOutFailures"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PasswordLockoutPolicyAddedEvent) CheckPrevious() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *PasswordLockoutPolicyAddedEvent) Data() interface{} {
|
||||||
|
return e
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPasswordLockoutPolicyAddedEvent(
|
||||||
|
ctx context.Context,
|
||||||
|
service string,
|
||||||
|
maxAttempts int,
|
||||||
|
showLockOutFailures bool,
|
||||||
|
) *PasswordLockoutPolicyAddedEvent {
|
||||||
|
|
||||||
|
return &PasswordLockoutPolicyAddedEvent{
|
||||||
|
BaseEvent: *eventstore.NewBaseEventForPush(
|
||||||
|
ctx,
|
||||||
|
service,
|
||||||
|
LabelPolicyAddedEventType,
|
||||||
|
),
|
||||||
|
MaxAttempts: maxAttempts,
|
||||||
|
ShowLockOutFailures: showLockOutFailures,
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user