2022-03-28 08:05:09 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/command/preparation"
|
|
|
|
"github.com/zitadel/zitadel/internal/eventstore"
|
|
|
|
"github.com/zitadel/zitadel/internal/repository/instance"
|
2022-03-28 08:05:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func AddDefaultLabelPolicy(
|
|
|
|
a *instance.Aggregate,
|
|
|
|
primaryColor,
|
|
|
|
backgroundColor,
|
|
|
|
warnColor,
|
|
|
|
fontColor,
|
|
|
|
primaryColorDark,
|
|
|
|
backgroundColorDark,
|
|
|
|
warnColorDark,
|
|
|
|
fontColorDark string,
|
|
|
|
hideLoginNameSuffix,
|
|
|
|
errorMsgPopup,
|
|
|
|
disableWatermark bool,
|
|
|
|
) preparation.Validation {
|
|
|
|
return func() (preparation.CreateCommands, error) {
|
|
|
|
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
|
|
|
//TODO: check if already exists
|
|
|
|
return []eventstore.Command{
|
|
|
|
instance.NewLabelPolicyAddedEvent(ctx, &a.Aggregate,
|
|
|
|
primaryColor,
|
|
|
|
backgroundColor,
|
|
|
|
warnColor,
|
|
|
|
fontColor,
|
|
|
|
primaryColorDark,
|
|
|
|
backgroundColorDark,
|
|
|
|
warnColorDark,
|
|
|
|
fontColorDark,
|
|
|
|
hideLoginNameSuffix,
|
|
|
|
errorMsgPopup,
|
|
|
|
disableWatermark,
|
|
|
|
),
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
}
|
2022-03-29 09:53:19 +00:00
|
|
|
|
|
|
|
func ActivateDefaultLabelPolicy(
|
|
|
|
a *instance.Aggregate,
|
|
|
|
) preparation.Validation {
|
|
|
|
return func() (preparation.CreateCommands, error) {
|
|
|
|
return func(ctx context.Context, filter preparation.FilterToQueryReducer) ([]eventstore.Command, error) {
|
|
|
|
//TODO: check if already exists
|
|
|
|
return []eventstore.Command{
|
|
|
|
instance.NewLabelPolicyActivatedEvent(ctx, &a.Aggregate),
|
|
|
|
}, nil
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
}
|