mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-13 03:24:26 +00:00
b363ddd707
* feat: implement projection for iam and clean up code * feat: add migration * fix: remove unused tests * fix: handler
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
|
|
iam_model "github.com/caos/zitadel/internal/iam/model"
|
|
)
|
|
|
|
type LabelPolicy struct {
|
|
es_models.ObjectRoot
|
|
State int32 `json:"-"`
|
|
PrimaryColor string `json:"primaryColor"`
|
|
BackgroundColor string `json:"backgroundColor"`
|
|
FontColor string `json:"fontColor"`
|
|
WarnColor string `json:"warnColor"`
|
|
PrimaryColorDark string `json:"primaryColorDark"`
|
|
BackgroundColorDark string `json:"backgroundColorDark"`
|
|
FontColorDark string `json:"fontColorDark"`
|
|
WarnColorDark string `json:"warnColorDark"`
|
|
HideLoginNameSuffix bool `json:"hideLoginNameSuffix"`
|
|
}
|
|
|
|
func LabelPolicyToModel(policy *LabelPolicy) *iam_model.LabelPolicy {
|
|
return &iam_model.LabelPolicy{
|
|
ObjectRoot: policy.ObjectRoot,
|
|
State: iam_model.PolicyState(policy.State),
|
|
PrimaryColor: policy.PrimaryColor,
|
|
BackgroundColor: policy.BackgroundColor,
|
|
WarnColor: policy.WarnColor,
|
|
FontColor: policy.FontColor,
|
|
PrimaryColorDark: policy.PrimaryColorDark,
|
|
BackgroundColorDark: policy.BackgroundColorDark,
|
|
WarnColorDark: policy.WarnColorDark,
|
|
FontColorDark: policy.FontColorDark,
|
|
HideLoginNameSuffix: policy.HideLoginNameSuffix,
|
|
}
|
|
}
|
|
|
|
func (p *LabelPolicy) SetDataLabel(event *es_models.Event) error {
|
|
err := json.Unmarshal(event.Data, p)
|
|
if err != nil {
|
|
return errors.ThrowInternal(err, "MODEL-Gdgwq", "unable to unmarshal data")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (p *IDPProvider) SetDataLabel(event *es_models.Event) error {
|
|
err := json.Unmarshal(event.Data, p)
|
|
if err != nil {
|
|
return errors.ThrowInternal(err, "MODEL-c41Hn", "unable to unmarshal data")
|
|
}
|
|
return nil
|
|
}
|