mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-08 19:27:41 +00:00
ebeedd1346
member not working atm
55 lines
1.0 KiB
Go
55 lines
1.0 KiB
Go
package provider
|
|
|
|
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 (
|
|
AddedEventType = "idpprovider.added"
|
|
)
|
|
|
|
type AddedEvent struct {
|
|
eventstore.BaseEvent
|
|
|
|
IDPConfigID string `json:"idpConfigId"`
|
|
IDPProviderType Type `json:"idpProviderType"`
|
|
}
|
|
|
|
func (e *AddedEvent) CheckPrevious() bool {
|
|
return true
|
|
}
|
|
|
|
func (e *AddedEvent) Data() interface{} {
|
|
return e
|
|
}
|
|
|
|
func NewAddedEvent(
|
|
base *eventstore.BaseEvent,
|
|
idpConfigID string,
|
|
idpProviderType Type,
|
|
) *AddedEvent {
|
|
|
|
return &AddedEvent{
|
|
BaseEvent: *base,
|
|
IDPConfigID: idpConfigID,
|
|
IDPProviderType: idpProviderType,
|
|
}
|
|
}
|
|
|
|
func AddedEventEventMapper(event *repository.Event) (eventstore.EventReader, error) {
|
|
e := &AddedEvent{
|
|
BaseEvent: *eventstore.BaseEventFromRepo(event),
|
|
}
|
|
|
|
err := json.Unmarshal(event.Data, e)
|
|
if err != nil {
|
|
return nil, errors.ThrowInternal(err, "PROVI-bfNnp", "Errors.Internal")
|
|
}
|
|
|
|
return e, nil
|
|
}
|