mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-27 06:38:46 +00:00
try with writemodel
This commit is contained in:
@@ -2,30 +2,40 @@ package idp
|
||||
|
||||
import "github.com/caos/zitadel/internal/eventstore/v2"
|
||||
|
||||
type AddedEvent struct {
|
||||
type ConfigAddedEvent struct {
|
||||
eventstore.BaseEvent
|
||||
|
||||
ID string `idpConfigId`
|
||||
Name string `name`
|
||||
ID string `json:"idpConfigId"`
|
||||
Name string `json:"name"`
|
||||
Type ConfigType `json:"idpType,omitempty"`
|
||||
StylingType StylingType `json:"stylingType,omitempty"`
|
||||
}
|
||||
|
||||
func NewAddedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
configID string,
|
||||
name string,
|
||||
) *AddedEvent {
|
||||
configType ConfigType,
|
||||
stylingType StylingType,
|
||||
) *ConfigAddedEvent {
|
||||
|
||||
return &AddedEvent{
|
||||
BaseEvent: *base,
|
||||
ID: configID,
|
||||
Name: name,
|
||||
return &ConfigAddedEvent{
|
||||
BaseEvent: *base,
|
||||
ID: configID,
|
||||
Name: name,
|
||||
StylingType: stylingType,
|
||||
Type: configType,
|
||||
}
|
||||
}
|
||||
|
||||
func (e *AddedEvent) CheckPrevious() bool {
|
||||
func (e *ConfigAddedEvent) CheckPrevious() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *AddedEvent) Data() interface{} {
|
||||
func (e *ConfigAddedEvent) Data() interface{} {
|
||||
return e
|
||||
}
|
||||
|
||||
type ConfigType uint32
|
||||
|
||||
type StylingType uint32
|
||||
|
||||
@@ -1,35 +1,51 @@
|
||||
package idp
|
||||
|
||||
import "github.com/caos/zitadel/internal/eventstore/v2"
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/errors"
|
||||
"github.com/caos/zitadel/internal/eventstore/v2"
|
||||
)
|
||||
|
||||
type ChangedEdvent struct {
|
||||
type ConfigChangedEvent struct {
|
||||
eventstore.BaseEvent `json:"-"`
|
||||
|
||||
current *ConfigAggregate
|
||||
changed *ConfigAggregate
|
||||
ID string `json:"idpConfigId"`
|
||||
StylingType StylingType `json:"stylingType,omitempty"`
|
||||
|
||||
Name string `json:"name"`
|
||||
hasChanged bool
|
||||
}
|
||||
|
||||
func ChangedEvent(
|
||||
func NewConfigChangedEvent(
|
||||
base *eventstore.BaseEvent,
|
||||
current *ConfigAggregate,
|
||||
changed *ConfigAggregate,
|
||||
) (*ChangedEdvent, error) {
|
||||
//TODO: who to handle chanes?
|
||||
) (*ConfigChangedEvent, error) {
|
||||
|
||||
return &ChangedEdvent{
|
||||
change := &ConfigChangedEvent{
|
||||
BaseEvent: *base,
|
||||
current: current,
|
||||
changed: changed,
|
||||
}, nil
|
||||
}
|
||||
|
||||
if current.ConfigID != changed.ConfigID {
|
||||
change.ID = changed.ConfigID
|
||||
change.hasChanged = true
|
||||
}
|
||||
|
||||
if current.StylingType != changed.StylingType {
|
||||
change.StylingType = changed.StylingType
|
||||
change.hasChanged = true
|
||||
}
|
||||
|
||||
if !change.hasChanged {
|
||||
return nil, errors.ThrowPreconditionFailed(nil, "IDP-UBJbB", "Errors.NoChanges")
|
||||
}
|
||||
|
||||
return change, nil
|
||||
}
|
||||
|
||||
func (e *ChangedEdvent) CheckPrevious() bool {
|
||||
func (e *ConfigChangedEvent) CheckPrevious() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (e *ChangedEdvent) Data() interface{} {
|
||||
func (e *ConfigChangedEvent) Data() interface{} {
|
||||
if e.current.Name != e.changed.Name {
|
||||
e.Name = e.changed.Name
|
||||
}
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
package oidc
|
||||
|
||||
type AddedEvent struct{}
|
||||
import "github.com/caos/zitadel/internal/crypto"
|
||||
|
||||
type AddedEvent struct {
|
||||
eventstore.BaseEvent
|
||||
|
||||
IDPConfigID string `json:"idpConfigId"`
|
||||
ClientID string `json:"clientId"`
|
||||
Secret *crypto.CryptoValue `json:"clientSecret"`
|
||||
Issuer string `json:"issuer"`
|
||||
Scopes []string `json:"scpoes"`
|
||||
IDPDisplayNameMapping int32 `json:"idpDisplayNameMapping,omitempty"`
|
||||
UsernameMapping int32 `json:"usernameMapping,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user