fix: change to repository event types and removed unused code (#3386)

* fix: change to repository event types and removed unused code

* some fixes

* remove unused code
This commit is contained in:
Livio Amstutz
2022-03-31 11:36:26 +02:00
committed by GitHub
parent 55af4a18a2
commit 87560157c1
170 changed files with 999 additions and 9581 deletions

View File

@@ -1,93 +0,0 @@
package model
import (
"encoding/json"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/domain"
caos_errs "github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/model"
)
const (
IAMVersion = "v1"
)
type Step int
const (
Step1 = Step(model.Step1)
Step2 = Step(model.Step2)
StepCount = Step(model.StepCount)
)
type IAM struct {
es_models.ObjectRoot
SetUpStarted Step `json:"-"`
SetUpDone Step `json:"-"`
GlobalOrgID string `json:"globalOrgId,omitempty"`
IAMProjectID string `json:"iamProjectId,omitempty"`
}
func IAMToModel(iam *IAM) *model.IAM {
converted := &model.IAM{
ObjectRoot: iam.ObjectRoot,
SetUpStarted: domain.Step(iam.SetUpStarted),
SetUpDone: domain.Step(iam.SetUpDone),
GlobalOrgID: iam.GlobalOrgID,
IAMProjectID: iam.IAMProjectID,
}
return converted
}
func (i *IAM) AppendEvents(events ...*es_models.Event) error {
for _, event := range events {
if err := i.AppendEvent(event); err != nil {
return err
}
}
return nil
}
func (i *IAM) AppendEvent(event *es_models.Event) (err error) {
i.ObjectRoot.AppendEvent(event)
switch event.Type {
case IAMSetupStarted:
if len(event.Data) == 0 {
i.SetUpStarted = Step(model.Step1)
return
}
step := new(struct{ Step Step })
err = json.Unmarshal(event.Data, step)
if err != nil {
return err
}
i.SetUpStarted = step.Step
case IAMSetupDone:
if len(event.Data) == 0 {
i.SetUpDone = Step(model.Step1)
return
}
step := new(struct{ Step Step })
err = json.Unmarshal(event.Data, step)
if err != nil {
return err
}
i.SetUpDone = step.Step
case IAMProjectSet,
GlobalOrgSet:
err = i.SetData(event)
}
return err
}
func (i *IAM) SetData(event *es_models.Event) error {
i.ObjectRoot.AppendEvent(event)
if err := json.Unmarshal(event.Data, i); err != nil {
logging.Log("EVEN-9sie4").WithError(err).Error("could not unmarshal event data")
return caos_errs.ThrowInternal(err, "MODEL-slwi3", "could not unmarshal event")
}
return nil
}

View File

@@ -1,75 +0,0 @@
package model
import (
"encoding/json"
"testing"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
)
func mockIamData(iam *IAM) []byte {
data, _ := json.Marshal(iam)
return data
}
func TestProjectRoleAppendEvent(t *testing.T) {
type args struct {
event *es_models.Event
iam *IAM
}
tests := []struct {
name string
args args
result *IAM
}{
{
name: "append set up start event",
args: args{
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: IAMSetupStarted, ResourceOwner: "OrgID"},
iam: &IAM{},
},
result: &IAM{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, SetUpStarted: Step1},
},
{
name: "append set up done event",
args: args{
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: IAMSetupDone, ResourceOwner: "OrgID"},
iam: &IAM{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, SetUpStarted: Step1},
},
result: &IAM{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, SetUpStarted: Step1, SetUpDone: Step1},
},
{
name: "append globalorg event",
args: args{
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: GlobalOrgSet, ResourceOwner: "OrgID", Data: mockIamData(&IAM{GlobalOrgID: "GlobalOrg"})},
iam: &IAM{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, SetUpStarted: Step1},
},
result: &IAM{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, SetUpStarted: Step1, GlobalOrgID: "GlobalOrg"},
},
{
name: "append iamproject event",
args: args{
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: IAMProjectSet, ResourceOwner: "OrgID", Data: mockIamData(&IAM{IAMProjectID: "IamProject"})},
iam: &IAM{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, SetUpStarted: Step1},
},
result: &IAM{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID"}, SetUpStarted: Step1, IAMProjectID: "IamProject"},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
tt.args.iam.AppendEvent(tt.args.event)
if tt.args.iam.AggregateID != tt.result.AggregateID {
t.Errorf("got wrong result AggregateID: expected: %v, actual: %v ", tt.result.AggregateID, tt.args.iam.AggregateID)
}
if tt.args.iam.SetUpDone != tt.result.SetUpDone {
t.Errorf("got wrong result SetUpDone: expected: %v, actual: %v ", tt.result.SetUpDone, tt.args.iam.SetUpDone)
}
if tt.args.iam.GlobalOrgID != tt.result.GlobalOrgID {
t.Errorf("got wrong result GlobalOrgID: expected: %v, actual: %v ", tt.result.GlobalOrgID, tt.args.iam.GlobalOrgID)
}
if tt.args.iam.IAMProjectID != tt.result.IAMProjectID {
t.Errorf("got wrong result IAMProjectID: expected: %v, actual: %v ", tt.result.IAMProjectID, tt.args.iam.IAMProjectID)
}
})
}
}

View File

@@ -1,78 +0,0 @@
package model
import (
"encoding/json"
"github.com/caos/logging"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/model"
)
type IDPConfig struct {
es_models.ObjectRoot
IDPConfigID string `json:"idpConfigId"`
State int32 `json:"-"`
Name string `json:"name,omitempty"`
Type int32 `json:"idpType,omitempty"`
StylingType int32 `json:"stylingType,omitempty"`
OIDCIDPConfig *OIDCIDPConfig `json:"-"`
}
type IDPConfigID struct {
es_models.ObjectRoot
IDPConfigID string `json:"idpConfigId"`
}
func GetIDPConfig(idps []*IDPConfig, id string) (int, *IDPConfig) {
for i, idp := range idps {
if idp.IDPConfigID == id {
return i, idp
}
}
return -1, nil
}
func (c *IDPConfig) Changes(changed *IDPConfig) map[string]interface{} {
changes := make(map[string]interface{}, 1)
changes["idpConfigId"] = c.IDPConfigID
if changed.Name != "" && c.Name != changed.Name {
changes["name"] = changed.Name
}
if c.StylingType != changed.StylingType {
changes["stylingType"] = changed.StylingType
}
return changes
}
func IDPConfigsToModel(idps []*IDPConfig) []*model.IDPConfig {
convertedIDPConfigs := make([]*model.IDPConfig, len(idps))
for i, idp := range idps {
convertedIDPConfigs[i] = IDPConfigToModel(idp)
}
return convertedIDPConfigs
}
func IDPConfigToModel(idp *IDPConfig) *model.IDPConfig {
converted := &model.IDPConfig{
ObjectRoot: idp.ObjectRoot,
IDPConfigID: idp.IDPConfigID,
Name: idp.Name,
StylingType: model.IDPStylingType(idp.StylingType),
State: model.IDPConfigState(idp.State),
Type: model.IdpConfigType(idp.Type),
}
if idp.OIDCIDPConfig != nil {
converted.OIDCConfig = OIDCIDPConfigToModel(idp.OIDCIDPConfig)
}
return converted
}
func (c *IDPConfig) SetData(event *es_models.Event) error {
c.ObjectRoot.AppendEvent(event)
if err := json.Unmarshal(event.Data, c); err != nil {
logging.Log("EVEN-Msj9w").WithError(err).Error("could not unmarshal event data")
return err
}
return nil
}

View File

@@ -1,49 +0,0 @@
package model
import (
"testing"
)
func TestIdpConfigChanges(t *testing.T) {
type args struct {
existing *IDPConfig
new *IDPConfig
}
type res struct {
changesLen int
}
tests := []struct {
name string
args args
res res
}{
{
name: "idp config name changes",
args: args{
existing: &IDPConfig{IDPConfigID: "IDPConfigID", Name: "Name"},
new: &IDPConfig{IDPConfigID: "IDPConfigID", Name: "NameChanged"},
},
res: res{
changesLen: 2,
},
},
{
name: "no changes",
args: args{
existing: &IDPConfig{IDPConfigID: "IDPConfigID", Name: "Name"},
new: &IDPConfig{IDPConfigID: "IDPConfigID", Name: "Name"},
},
res: res{
changesLen: 1,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
changes := tt.args.existing.Changes(tt.args.new)
if len(changes) != tt.res.changesLen {
t.Errorf("got wrong changes len: expected: %v, actual: %v ", tt.res.changesLen, len(changes))
}
})
}
}

View File

@@ -1,55 +0,0 @@
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
}

View File

@@ -1,46 +0,0 @@
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 LockoutPolicy struct {
es_models.ObjectRoot
State int32 `json:"-"`
MaxPasswordAttempts uint64 `json:"maxPasswordAttempts"`
ShowLockOutFailures bool `json:"showLockOutFailures"`
}
func LockoutPolicyToModel(policy *LockoutPolicy) *iam_model.LockoutPolicy {
return &iam_model.LockoutPolicy{
ObjectRoot: policy.ObjectRoot,
State: iam_model.PolicyState(policy.State),
MaxPasswordAttempts: policy.MaxPasswordAttempts,
ShowLockOutFailures: policy.ShowLockOutFailures,
}
}
func (p *LockoutPolicy) Changes(changed *LockoutPolicy) map[string]interface{} {
changes := make(map[string]interface{}, 2)
if p.MaxPasswordAttempts != changed.MaxPasswordAttempts {
changes["maxAttempts"] = changed.MaxPasswordAttempts
}
if p.ShowLockOutFailures != changed.ShowLockOutFailures {
changes["showLockOutFailures"] = changed.ShowLockOutFailures
}
return changes
}
func (p *LockoutPolicy) SetData(event *es_models.Event) error {
err := json.Unmarshal(event.Data, p)
if err != nil {
return errors.ThrowInternal(err, "EVENT-7JS9d", "unable to unmarshal data")
}
return nil
}

View File

@@ -1,49 +0,0 @@
package model
import (
"testing"
)
func TestPasswordLockoutPolicyChanges(t *testing.T) {
type args struct {
existing *LockoutPolicy
new *LockoutPolicy
}
type res struct {
changesLen int
}
tests := []struct {
name string
args args
res res
}{
{
name: "lockout policy all attributes change",
args: args{
existing: &LockoutPolicy{MaxPasswordAttempts: 365, ShowLockOutFailures: true},
new: &LockoutPolicy{MaxPasswordAttempts: 730, ShowLockOutFailures: false},
},
res: res{
changesLen: 2,
},
},
{
name: "no changes",
args: args{
existing: &LockoutPolicy{MaxPasswordAttempts: 10, ShowLockOutFailures: true},
new: &LockoutPolicy{MaxPasswordAttempts: 10, ShowLockOutFailures: true},
},
res: res{
changesLen: 0,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
changes := tt.args.existing.Changes(tt.args.new)
if len(changes) != tt.res.changesLen {
t.Errorf("got wrong changes len: expected: %v, actual: %v ", tt.res.changesLen, len(changes))
}
})
}
}

View File

@@ -1,149 +0,0 @@
package model
import (
"encoding/json"
"github.com/caos/zitadel/internal/domain"
"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 LoginPolicy struct {
es_models.ObjectRoot
State int32 `json:"-"`
AllowUsernamePassword bool `json:"allowUsernamePassword"`
AllowRegister bool `json:"allowRegister"`
AllowExternalIdp bool `json:"allowExternalIdp"`
ForceMFA bool `json:"forceMFA"`
PasswordlessType int32 `json:"passwordlessType"`
IDPProviders []*IDPProvider `json:"-"`
SecondFactors []int32 `json:"-"`
MultiFactors []int32 `json:"-"`
}
type IDPProvider struct {
es_models.ObjectRoot
Type int32 `json:"idpProviderType"`
IDPConfigID string `json:"idpConfigId"`
}
type IDPProviderID struct {
IDPConfigID string `json:"idpConfigId"`
}
type MFA struct {
MFAType int32 `json:"mfaType"`
}
func GetIDPProvider(providers []*IDPProvider, id string) (int, *IDPProvider) {
for i, p := range providers {
if p.IDPConfigID == id {
return i, p
}
}
return -1, nil
}
func GetMFA(mfas []int32, mfaType int32) (int, int32) {
for i, m := range mfas {
if m == mfaType {
return i, m
}
}
return -1, 0
}
func LoginPolicyToModel(policy *LoginPolicy) *iam_model.LoginPolicy {
idps := IDPProvidersToModel(policy.IDPProviders)
secondFactors := SecondFactorsToModel(policy.SecondFactors)
multiFactors := MultiFactorsToModel(policy.MultiFactors)
return &iam_model.LoginPolicy{
ObjectRoot: policy.ObjectRoot,
State: iam_model.PolicyState(policy.State),
AllowUsernamePassword: policy.AllowUsernamePassword,
AllowRegister: policy.AllowRegister,
AllowExternalIdp: policy.AllowExternalIdp,
IDPProviders: idps,
ForceMFA: policy.ForceMFA,
SecondFactors: secondFactors,
MultiFactors: multiFactors,
PasswordlessType: iam_model.PasswordlessType(policy.PasswordlessType),
}
}
func IDPProvidersToModel(members []*IDPProvider) []*iam_model.IDPProvider {
convertedProviders := make([]*iam_model.IDPProvider, len(members))
for i, m := range members {
convertedProviders[i] = IDPProviderToModel(m)
}
return convertedProviders
}
func IDPProviderToModel(provider *IDPProvider) *iam_model.IDPProvider {
return &iam_model.IDPProvider{
ObjectRoot: provider.ObjectRoot,
Type: iam_model.IDPProviderType(provider.Type),
IDPConfigID: provider.IDPConfigID,
}
}
func SecondFactorsToModel(mfas []int32) []domain.SecondFactorType {
convertedMFAs := make([]domain.SecondFactorType, len(mfas))
for i, mfa := range mfas {
convertedMFAs[i] = domain.SecondFactorType(mfa)
}
return convertedMFAs
}
func MultiFactorsToModel(mfas []int32) []domain.MultiFactorType {
convertedMFAs := make([]domain.MultiFactorType, len(mfas))
for i, mfa := range mfas {
convertedMFAs[i] = domain.MultiFactorType(mfa)
}
return convertedMFAs
}
func (p *LoginPolicy) Changes(changed *LoginPolicy) map[string]interface{} {
changes := make(map[string]interface{}, 2)
if changed.AllowUsernamePassword != p.AllowUsernamePassword {
changes["allowUsernamePassword"] = changed.AllowUsernamePassword
}
if changed.AllowRegister != p.AllowRegister {
changes["allowRegister"] = changed.AllowRegister
}
if changed.AllowExternalIdp != p.AllowExternalIdp {
changes["allowExternalIdp"] = changed.AllowExternalIdp
}
if changed.ForceMFA != p.ForceMFA {
changes["forceMFA"] = changed.ForceMFA
}
if changed.PasswordlessType != p.PasswordlessType {
changes["passwordlessType"] = changed.PasswordlessType
}
return changes
}
func (p *LoginPolicy) SetData(event *es_models.Event) error {
err := json.Unmarshal(event.Data, p)
if err != nil {
return errors.ThrowInternal(err, "EVENT-7JS9d", "unable to unmarshal data")
}
return nil
}
func (p *IDPProvider) SetData(event *es_models.Event) error {
err := json.Unmarshal(event.Data, p)
if err != nil {
return errors.ThrowInternal(err, "EVENT-ldos9", "unable to unmarshal data")
}
return nil
}
func (m *MFA) SetData(event *es_models.Event) error {
err := json.Unmarshal(event.Data, m)
if err != nil {
return errors.ThrowInternal(err, "EVENT-4G9os", "unable to unmarshal data")
}
return nil
}

View File

@@ -1,41 +0,0 @@
package model
import (
b64 "encoding/base64"
"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 MailTemplate struct {
es_models.ObjectRoot
State int32 `json:"-"`
Template []byte
}
func MailTemplateToModel(template *MailTemplate) *iam_model.MailTemplate {
return &iam_model.MailTemplate{
ObjectRoot: template.ObjectRoot,
State: iam_model.PolicyState(template.State),
Template: template.Template,
}
}
func (p *MailTemplate) Changes(changed *MailTemplate) map[string]interface{} {
changes := make(map[string]interface{}, 1)
if b64.StdEncoding.EncodeToString(changed.Template) != b64.StdEncoding.EncodeToString(p.Template) {
changes["template"] = b64.StdEncoding.EncodeToString(changed.Template)
}
return changes
}
func (p *MailTemplate) SetDataLabel(event *es_models.Event) error {
err := json.Unmarshal(event.Data, p)
if err != nil {
return errors.ThrowInternal(err, "MODEL-ikjhf", "unable to unmarshal data")
}
return nil
}

View File

@@ -1,49 +0,0 @@
package model
import (
"testing"
)
func TestMailTemplateChanges(t *testing.T) {
type args struct {
existing *MailTemplate
new *MailTemplate
}
type res struct {
changesLen int
}
tests := []struct {
name string
args args
res res
}{
{
name: "mailtemplate all attributes change",
args: args{
existing: &MailTemplate{Template: []byte("<doctype html>")},
new: &MailTemplate{Template: []byte("<!doctype html>")},
},
res: res{
changesLen: 1,
},
},
{
name: "no changes",
args: args{
existing: &MailTemplate{Template: []byte("<!doctype html>")},
new: &MailTemplate{Template: []byte("<!doctype html>")},
},
res: res{
changesLen: 0,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
changes := tt.args.existing.Changes(tt.args.new)
if len(changes) != tt.res.changesLen {
t.Errorf("got wrong changes len: expected: %v, actual: %v ", tt.res.changesLen, len(changes))
}
})
}
}

View File

@@ -1,119 +0,0 @@
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 MailText struct {
es_models.ObjectRoot
State int32 `json:"-"`
MailTextType string
Language string
Title string
PreHeader string
Subject string
Greeting string
Text string
ButtonText string
}
func GetMailText(mailTexts []*MailText, mailTextType string, language string) (int, *MailText) {
for i, m := range mailTexts {
if m.MailTextType == mailTextType && m.Language == language {
return i, m
}
}
return -1, nil
}
func MailTextsToModel(mailTexts []*MailText) []*iam_model.MailText {
convertedMailTexts := make([]*iam_model.MailText, len(mailTexts))
for i, m := range mailTexts {
convertedMailTexts[i] = MailTextToModel(m)
}
return convertedMailTexts
}
func MailTextToModel(mailText *MailText) *iam_model.MailText {
return &iam_model.MailText{
ObjectRoot: mailText.ObjectRoot,
State: iam_model.PolicyState(mailText.State),
MailTextType: mailText.MailTextType,
Language: mailText.Language,
Title: mailText.Title,
PreHeader: mailText.PreHeader,
Subject: mailText.Subject,
Greeting: mailText.Greeting,
Text: mailText.Text,
ButtonText: mailText.ButtonText,
}
}
func MailTextsFromModel(mailTexts []*iam_model.MailText) []*MailText {
convertedMailTexts := make([]*MailText, len(mailTexts))
for i, m := range mailTexts {
convertedMailTexts[i] = MailTextFromModel(m)
}
return convertedMailTexts
}
func MailTextFromModel(mailText *iam_model.MailText) *MailText {
return &MailText{
ObjectRoot: mailText.ObjectRoot,
State: int32(mailText.State),
MailTextType: mailText.MailTextType,
Language: mailText.Language,
Title: mailText.Title,
PreHeader: mailText.PreHeader,
Subject: mailText.Subject,
Greeting: mailText.Greeting,
Text: mailText.Text,
ButtonText: mailText.ButtonText,
}
}
func (p *MailText) Changes(changed *MailText) map[string]interface{} {
changes := make(map[string]interface{}, 8)
changes["mailTextType"] = changed.MailTextType
changes["language"] = changed.Language
if changed.Title != p.Title {
changes["title"] = changed.Title
}
if changed.PreHeader != p.PreHeader {
changes["preHeader"] = changed.PreHeader
}
if changed.Subject != p.Subject {
changes["subject"] = changed.Subject
}
if changed.Greeting != p.Greeting {
changes["greeting"] = changed.Greeting
}
if changed.Text != p.Text {
changes["text"] = changed.Text
}
if changed.ButtonText != p.ButtonText {
changes["buttonText"] = changed.ButtonText
}
return changes
}
func (p *MailText) SetDataLabel(event *es_models.Event) error {
err := json.Unmarshal(event.Data, p)
if err != nil {
return errors.ThrowInternal(err, "MODEL-3FUV5", "unable to unmarshal data")
}
return nil
}

View File

@@ -1,69 +0,0 @@
package model
import (
"encoding/json"
"reflect"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/crypto"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/model"
"github.com/lib/pq"
)
type OIDCIDPConfig struct {
es_models.ObjectRoot
IDPConfigID string `json:"idpConfigId"`
ClientID string `json:"clientId"`
ClientSecret *crypto.CryptoValue `json:"clientSecret,omitempty"`
Issuer string `json:"issuer,omitempty"`
Scopes pq.StringArray `json:"scopes,omitempty"`
IDPDisplayNameMapping int32 `json:"idpDisplayNameMapping,omitempty"`
UsernameMapping int32 `json:"usernameMapping,omitempty"`
}
func (c *OIDCIDPConfig) Changes(changed *OIDCIDPConfig) map[string]interface{} {
changes := make(map[string]interface{}, 1)
changes["idpConfigId"] = c.IDPConfigID
if c.ClientID != changed.ClientID {
changes["clientId"] = changed.ClientID
}
if changed.ClientSecret != nil && c.ClientSecret != changed.ClientSecret {
changes["clientSecret"] = changed.ClientSecret
}
if c.Issuer != changed.Issuer {
changes["issuer"] = changed.Issuer
}
if !reflect.DeepEqual(c.Scopes, changed.Scopes) {
changes["scopes"] = changed.Scopes
}
if c.IDPDisplayNameMapping != changed.IDPDisplayNameMapping {
changes["idpDisplayNameMapping"] = changed.IDPDisplayNameMapping
}
if c.UsernameMapping != changed.UsernameMapping {
changes["usernameMapping"] = changed.UsernameMapping
}
return changes
}
func OIDCIDPConfigToModel(config *OIDCIDPConfig) *model.OIDCIDPConfig {
return &model.OIDCIDPConfig{
ObjectRoot: config.ObjectRoot,
IDPConfigID: config.IDPConfigID,
ClientID: config.ClientID,
ClientSecret: config.ClientSecret,
Issuer: config.Issuer,
Scopes: config.Scopes,
IDPDisplayNameMapping: model.OIDCMappingField(config.IDPDisplayNameMapping),
UsernameMapping: model.OIDCMappingField(config.UsernameMapping),
}
}
func (o *OIDCIDPConfig) SetData(event *es_models.Event) error {
o.ObjectRoot.AppendEvent(event)
if err := json.Unmarshal(event.Data, o); err != nil {
logging.Log("EVEN-Msh8s").WithError(err).Error("could not unmarshal event data")
return err
}
return nil
}

View File

@@ -1,73 +0,0 @@
package model
import (
"testing"
"github.com/caos/zitadel/internal/crypto"
)
func TestOIDCIdpConfigChanges(t *testing.T) {
type args struct {
existing *OIDCIDPConfig
new *OIDCIDPConfig
}
type res struct {
changesLen int
}
tests := []struct {
name string
args args
res res
}{
{
name: "all possible values change",
args: args{
existing: &OIDCIDPConfig{
IDPConfigID: "IDPConfigID",
ClientID: "ClientID",
ClientSecret: &crypto.CryptoValue{KeyID: "KeyID"},
Issuer: "Issuer",
Scopes: []string{"scope1"},
},
new: &OIDCIDPConfig{
IDPConfigID: "IDPConfigID",
ClientID: "ClientID2",
ClientSecret: &crypto.CryptoValue{KeyID: "KeyID2"},
Issuer: "Issuer2",
Scopes: []string{"scope1", "scope2"},
},
},
res: res{
changesLen: 5,
},
},
{
name: "no changes",
args: args{
existing: &OIDCIDPConfig{
IDPConfigID: "IDPConfigID",
ClientID: "ClientID",
Issuer: "Issuer",
Scopes: []string{"scope1"},
},
new: &OIDCIDPConfig{
IDPConfigID: "IDPConfigID",
ClientID: "ClientID",
Issuer: "Issuer",
Scopes: []string{"scope1"},
},
},
res: res{
changesLen: 1,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
changes := tt.args.existing.Changes(tt.args.new)
if len(changes) != tt.res.changesLen {
t.Errorf("got wrong changes len: expected: %v, actual: %v ", tt.res.changesLen, len(changes))
}
})
}
}

View File

@@ -1,46 +0,0 @@
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 PasswordAgePolicy struct {
es_models.ObjectRoot
State int32 `json:"-"`
MaxAgeDays uint64 `json:"maxAgeDays"`
ExpireWarnDays uint64 `json:"expireWarnDays"`
}
func PasswordAgePolicyToModel(policy *PasswordAgePolicy) *iam_model.PasswordAgePolicy {
return &iam_model.PasswordAgePolicy{
ObjectRoot: policy.ObjectRoot,
State: iam_model.PolicyState(policy.State),
MaxAgeDays: policy.MaxAgeDays,
ExpireWarnDays: policy.ExpireWarnDays,
}
}
func (p *PasswordAgePolicy) Changes(changed *PasswordAgePolicy) map[string]interface{} {
changes := make(map[string]interface{}, 1)
if p.MaxAgeDays != changed.MaxAgeDays {
changes["maxAgeDays"] = changed.MaxAgeDays
}
if p.ExpireWarnDays != changed.ExpireWarnDays {
changes["expireWarnDays"] = changed.ExpireWarnDays
}
return changes
}
func (p *PasswordAgePolicy) SetData(event *es_models.Event) error {
err := json.Unmarshal(event.Data, p)
if err != nil {
return errors.ThrowInternal(err, "EVENT-7JS9d", "unable to unmarshal data")
}
return nil
}

View File

@@ -1,49 +0,0 @@
package model
import (
"testing"
)
func TestPasswordAgePolicyChanges(t *testing.T) {
type args struct {
existing *PasswordAgePolicy
new *PasswordAgePolicy
}
type res struct {
changesLen int
}
tests := []struct {
name string
args args
res res
}{
{
name: "age policy all attributes change",
args: args{
existing: &PasswordAgePolicy{MaxAgeDays: 365, ExpireWarnDays: 5},
new: &PasswordAgePolicy{MaxAgeDays: 730, ExpireWarnDays: 10},
},
res: res{
changesLen: 2,
},
},
{
name: "no changes",
args: args{
existing: &PasswordAgePolicy{MaxAgeDays: 10, ExpireWarnDays: 10},
new: &PasswordAgePolicy{MaxAgeDays: 10, ExpireWarnDays: 10},
},
res: res{
changesLen: 0,
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
changes := tt.args.existing.Changes(tt.args.new)
if len(changes) != tt.res.changesLen {
t.Errorf("got wrong changes len: expected: %v, actual: %v ", tt.res.changesLen, len(changes))
}
})
}
}

View File

@@ -1,40 +0,0 @@
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 PasswordComplexityPolicy struct {
es_models.ObjectRoot
State int32 `json:"-"`
MinLength uint64 `json:"minLength"`
HasLowercase bool `json:"hasLowercase"`
HasUppercase bool `json:"hasUppercase"`
HasNumber bool `json:"hasNumber"`
HasSymbol bool `json:"hasSymbol"`
}
func PasswordComplexityPolicyToModel(policy *PasswordComplexityPolicy) *iam_model.PasswordComplexityPolicy {
return &iam_model.PasswordComplexityPolicy{
ObjectRoot: policy.ObjectRoot,
State: iam_model.PolicyState(policy.State),
MinLength: policy.MinLength,
HasLowercase: policy.HasLowercase,
HasUppercase: policy.HasUppercase,
HasNumber: policy.HasNumber,
HasSymbol: policy.HasSymbol,
}
}
func (p *PasswordComplexityPolicy) SetData(event *es_models.Event) error {
err := json.Unmarshal(event.Data, p)
if err != nil {
return errors.ThrowInternal(err, "EVENT-7JS9d", "unable to unmarshal data")
}
return nil
}

View File

@@ -1,76 +0,0 @@
package model
import "github.com/caos/zitadel/internal/eventstore/v1/models"
const (
IAMAggregate models.AggregateType = "iam"
IAMSetupStarted models.EventType = "iam.setup.started"
IAMSetupDone models.EventType = "iam.setup.done"
GlobalOrgSet models.EventType = "iam.global.org.set"
IAMProjectSet models.EventType = "iam.project.iam.set"
IAMMemberAdded models.EventType = "iam.member.added"
IAMMemberChanged models.EventType = "iam.member.changed"
IAMMemberRemoved models.EventType = "iam.member.removed"
IAMMemberCascadeRemoved models.EventType = "iam.member.cascade.removed"
IDPConfigAdded models.EventType = "iam.idp.config.added"
IDPConfigChanged models.EventType = "iam.idp.config.changed"
IDPConfigRemoved models.EventType = "iam.idp.config.removed"
IDPConfigDeactivated models.EventType = "iam.idp.config.deactivated"
IDPConfigReactivated models.EventType = "iam.idp.config.reactivated"
OIDCIDPConfigAdded models.EventType = "iam.idp.oidc.config.added"
OIDCIDPConfigChanged models.EventType = "iam.idp.oidc.config.changed"
SAMLIDPConfigAdded models.EventType = "iam.idp.saml.config.added"
SAMLIDPConfigChanged models.EventType = "iam.idp.saml.config.changed"
LoginPolicyAdded models.EventType = "iam.policy.login.added"
LoginPolicyChanged models.EventType = "iam.policy.login.changed"
LoginPolicyIDPProviderAdded models.EventType = "iam.policy.login.idpprovider.added"
LoginPolicyIDPProviderRemoved models.EventType = "iam.policy.login.idpprovider.removed"
LoginPolicyIDPProviderCascadeRemoved models.EventType = "iam.policy.login.idpprovider.cascade.removed"
LoginPolicySecondFactorAdded models.EventType = "iam.policy.login.secondfactor.added"
LoginPolicySecondFactorRemoved models.EventType = "iam.policy.login.secondfactor.removed"
LoginPolicyMultiFactorAdded models.EventType = "iam.policy.login.multifactor.added"
LoginPolicyMultiFactorRemoved models.EventType = "iam.policy.login.multifactor.removed"
LabelPolicyAdded models.EventType = "iam.policy.label.added"
LabelPolicyChanged models.EventType = "iam.policy.label.changed"
LabelPolicyActivated models.EventType = "iam.policy.label.activated"
LabelPolicyLogoAdded models.EventType = "iam.policy.label.logo.added"
LabelPolicyLogoRemoved models.EventType = "iam.policy.label.logo.removed"
LabelPolicyIconAdded models.EventType = "iam.policy.label.icon.added"
LabelPolicyIconRemoved models.EventType = "iam.policy.label.icon.removed"
LabelPolicyLogoDarkAdded models.EventType = "iam.policy.label.logo.dark.added"
LabelPolicyLogoDarkRemoved models.EventType = "iam.policy.label.logo.dark.removed"
LabelPolicyIconDarkAdded models.EventType = "iam.policy.label.icon.dark.added"
LabelPolicyIconDarkRemoved models.EventType = "iam.policy.label.icon.dark.removed"
LabelPolicyFontAdded models.EventType = "iam.policy.label.font.added"
LabelPolicyFontRemoved models.EventType = "iam.policy.label.font.removed"
LabelPolicyAssetsRemoved models.EventType = "iam.policy.label.assets.removed"
MailTemplateAdded models.EventType = "iam.mail.template.added"
MailTemplateChanged models.EventType = "iam.mail.template.changed"
CustomTextSet models.EventType = "iam.customtext.set"
CustomTextRemoved models.EventType = "iam.customtext.removed"
CustomTextMessageRemoved models.EventType = "iam.customtext.template.removed"
PasswordComplexityPolicyAdded models.EventType = "iam.policy.password.complexity.added"
PasswordComplexityPolicyChanged models.EventType = "iam.policy.password.complexity.changed"
PasswordAgePolicyAdded models.EventType = "iam.policy.password.age.added"
PasswordAgePolicyChanged models.EventType = "iam.policy.password.age.changed"
LockoutPolicyAdded models.EventType = "iam.policy.lockout.added"
LockoutPolicyChanged models.EventType = "iam.policy.lockout.changed"
PrivacyPolicyAdded models.EventType = "iam.policy.privacy.added"
PrivacyPolicyChanged models.EventType = "iam.policy.privacy.changed"
OrgIAMPolicyAdded models.EventType = "iam.policy.org.iam.added"
OrgIAMPolicyChanged models.EventType = "iam.policy.org.iam.changed"
)

View File

@@ -1,897 +0,0 @@
package model
import (
"encoding/json"
"strings"
"time"
"golang.org/x/text/language"
"github.com/caos/zitadel/internal/domain"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
"github.com/caos/logging"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/v1/models"
)
const (
CustomTextKeyAggregateID = "aggregate_id"
CustomTextKeyTemplate = "template"
CustomTextKeyLanguage = "language"
CustomTextKeyKey = "key"
)
type CustomTextView struct {
AggregateID string `json:"-" gorm:"column:aggregate_id;primary_key"`
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
Template string `json:"template" gorm:"column:template;primary_key"`
Language string `json:"language" gorm:"column:language;primary_key"`
Key string `json:"key" gorm:"column:key;primary_key"`
Text string `json:"text" gorm:"column:text"`
Sequence uint64 `json:"-" gorm:"column:sequence"`
}
func (i *CustomTextView) AppendEvent(event *models.Event) (err error) {
i.Sequence = event.Sequence
switch event.Type {
case es_model.CustomTextSet, org_es_model.CustomTextSet:
i.setRootData(event)
err = i.SetData(event)
if err != nil {
return err
}
i.ChangeDate = event.CreationDate
}
return err
}
func (r *CustomTextView) setRootData(event *models.Event) {
r.AggregateID = event.AggregateID
}
func (r *CustomTextView) SetData(event *models.Event) error {
if err := json.Unmarshal(event.Data, r); err != nil {
logging.Log("MODEL-3n9fs").WithError(err).Error("could not unmarshal event data")
return caos_errs.ThrowInternal(err, "MODEL-5CVaR", "Could not unmarshal data")
}
return nil
}
func (r *CustomTextView) IsMessageTemplate() bool {
return r.Template == domain.InitCodeMessageType ||
r.Template == domain.PasswordResetMessageType ||
r.Template == domain.VerifyEmailMessageType ||
r.Template == domain.VerifyPhoneMessageType ||
r.Template == domain.DomainClaimedMessageType ||
r.Template == domain.PasswordlessRegistrationMessageType
}
func CustomTextViewsToLoginDomain(aggregateID, lang string, texts []*CustomTextView) *domain.CustomLoginText {
langTag := language.Make(lang)
result := &domain.CustomLoginText{
ObjectRoot: models.ObjectRoot{
AggregateID: aggregateID,
},
Language: langTag,
}
for _, text := range texts {
if text.CreationDate.Before(result.CreationDate) {
result.CreationDate = text.CreationDate
}
if text.ChangeDate.After(result.ChangeDate) {
result.ChangeDate = text.ChangeDate
}
if strings.HasPrefix(text.Key, domain.LoginKeySelectAccount) {
selectAccountKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyLogin) {
loginKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPassword) {
passwordKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyUsernameChange) {
usernameChangeKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyUsernameChangeDone) {
usernameChangeDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitPassword) {
initPasswordKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitPasswordDone) {
initPasswordDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyEmailVerification) {
emailVerificationKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyEmailVerificationDone) {
emailVerificationDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitializeUser) {
initializeUserKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitUserDone) {
initializeUserDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitMFAPrompt) {
initMFAPromptKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitMFAOTP) {
initMFAOTPKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitMFAU2F) {
initMFAU2FKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyInitMFADone) {
initMFADoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyMFAProviders) {
mfaProvidersKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyVerifyMFAOTP) {
verifyMFAOTPKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyVerifyMFAU2F) {
verifyMFAU2FKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPasswordless) {
passwordlessKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPasswordlessPrompt) {
passwordlessPromptKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPasswordlessRegistration) {
passwordlessRegistrationKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPasswordlessRegistrationDone) {
passwordlessRegistrationDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPasswordChange) {
passwordChangeKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPasswordChangeDone) {
passwordChangeDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyPasswordResetDone) {
passwordResetDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyRegistrationOption) {
registrationOptionKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyRegistrationUser) {
registrationUserKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyRegistrationOrg) {
registrationOrgKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyLinkingUserDone) {
linkingUserKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyExternalNotFound) {
externalUserNotFoundKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeySuccessLogin) {
successLoginKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyLogoutDone) {
logoutDoneKeyToDomain(text, result)
}
if strings.HasPrefix(text.Key, domain.LoginKeyFooter) {
footerKeyToDomain(text, result)
}
}
return result
}
func selectAccountKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeySelectAccountTitle {
result.SelectAccount.Title = text.Text
}
if text.Key == domain.LoginKeySelectAccountDescription {
result.SelectAccount.Description = text.Text
}
if text.Key == domain.LoginKeySelectAccountTitleLinkingProcess {
result.SelectAccount.TitleLinking = text.Text
}
if text.Key == domain.LoginKeySelectAccountDescriptionLinkingProcess {
result.SelectAccount.DescriptionLinking = text.Text
}
if text.Key == domain.LoginKeySelectAccountOtherUser {
result.SelectAccount.OtherUser = text.Text
}
if text.Key == domain.LoginKeySelectAccountSessionStateActive {
result.SelectAccount.SessionState0 = text.Text
}
if text.Key == domain.LoginKeySelectAccountSessionStateInactive {
result.SelectAccount.SessionState1 = text.Text
}
if text.Key == domain.LoginKeySelectAccountUserMustBeMemberOfOrg {
result.SelectAccount.MustBeMemberOfOrg = text.Text
}
}
func loginKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyLoginTitle {
result.Login.Title = text.Text
}
if text.Key == domain.LoginKeyLoginDescription {
result.Login.Description = text.Text
}
if text.Key == domain.LoginKeyLoginTitleLinkingProcess {
result.Login.TitleLinking = text.Text
}
if text.Key == domain.LoginKeyLoginDescriptionLinkingProcess {
result.Login.DescriptionLinking = text.Text
}
if text.Key == domain.LoginKeyLoginNameLabel {
result.Login.LoginNameLabel = text.Text
}
if text.Key == domain.LoginKeyLoginUsernamePlaceHolder {
result.Login.UsernamePlaceholder = text.Text
}
if text.Key == domain.LoginKeyLoginLoginnamePlaceHolder {
result.Login.LoginnamePlaceholder = text.Text
}
if text.Key == domain.LoginKeyLoginExternalUserDescription {
result.Login.ExternalUserDescription = text.Text
}
if text.Key == domain.LoginKeyLoginUserMustBeMemberOfOrg {
result.Login.MustBeMemberOfOrg = text.Text
}
if text.Key == domain.LoginKeyLoginRegisterButtonText {
result.Login.RegisterButtonText = text.Text
}
if text.Key == domain.LoginKeyLoginNextButtonText {
result.Login.NextButtonText = text.Text
}
}
func passwordKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordTitle {
result.Password.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordDescription {
result.Password.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordLabel {
result.Password.PasswordLabel = text.Text
}
if text.Key == domain.LoginKeyPasswordResetLinkText {
result.Password.ResetLinkText = text.Text
}
if text.Key == domain.LoginKeyPasswordBackButtonText {
result.Password.BackButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordNextButtonText {
result.Password.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordMinLength {
result.Password.MinLength = text.Text
}
if text.Key == domain.LoginKeyPasswordHasUppercase {
result.Password.HasUppercase = text.Text
}
if text.Key == domain.LoginKeyPasswordHasLowercase {
result.Password.HasLowercase = text.Text
}
if text.Key == domain.LoginKeyPasswordHasNumber {
result.Password.HasNumber = text.Text
}
if text.Key == domain.LoginKeyPasswordHasSymbol {
result.Password.HasSymbol = text.Text
}
if text.Key == domain.LoginKeyPasswordConfirmation {
result.Password.Confirmation = text.Text
}
}
func usernameChangeKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyUsernameChangeTitle {
result.UsernameChange.Title = text.Text
}
if text.Key == domain.LoginKeyUsernameChangeDescription {
result.UsernameChange.Description = text.Text
}
if text.Key == domain.LoginKeyUsernameChangeUsernameLabel {
result.UsernameChange.UsernameLabel = text.Text
}
if text.Key == domain.LoginKeyUsernameChangeCancelButtonText {
result.UsernameChange.CancelButtonText = text.Text
}
if text.Key == domain.LoginKeyUsernameChangeNextButtonText {
result.UsernameChange.NextButtonText = text.Text
}
}
func usernameChangeDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyUsernameChangeDoneTitle {
result.UsernameChangeDone.Title = text.Text
}
if text.Key == domain.LoginKeyUsernameChangeDoneDescription {
result.UsernameChangeDone.Description = text.Text
}
if text.Key == domain.LoginKeyUsernameChangeDoneNextButtonText {
result.UsernameChangeDone.NextButtonText = text.Text
}
}
func initPasswordKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitPasswordTitle {
result.InitPassword.Title = text.Text
}
if text.Key == domain.LoginKeyInitPasswordDescription {
result.InitPassword.Description = text.Text
}
if text.Key == domain.LoginKeyInitPasswordCodeLabel {
result.InitPassword.CodeLabel = text.Text
}
if text.Key == domain.LoginKeyInitPasswordNewPasswordLabel {
result.InitPassword.NewPasswordLabel = text.Text
}
if text.Key == domain.LoginKeyInitPasswordNewPasswordConfirmLabel {
result.InitPassword.NewPasswordConfirmLabel = text.Text
}
if text.Key == domain.LoginKeyInitPasswordNextButtonText {
result.InitPassword.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyInitPasswordResendButtonText {
result.InitPassword.ResendButtonText = text.Text
}
}
func initPasswordDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitPasswordDoneTitle {
result.InitPasswordDone.Title = text.Text
}
if text.Key == domain.LoginKeyInitPasswordDoneDescription {
result.InitPasswordDone.Description = text.Text
}
if text.Key == domain.LoginKeyInitPasswordDoneNextButtonText {
result.InitPasswordDone.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyInitPasswordDoneCancelButtonText {
result.InitPasswordDone.CancelButtonText = text.Text
}
}
func emailVerificationKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyEmailVerificationTitle {
result.EmailVerification.Title = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationDescription {
result.EmailVerification.Description = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationCodeLabel {
result.EmailVerification.CodeLabel = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationNextButtonText {
result.EmailVerification.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationResendButtonText {
result.EmailVerification.ResendButtonText = text.Text
}
}
func emailVerificationDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyEmailVerificationDoneTitle {
result.EmailVerificationDone.Title = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationDoneDescription {
result.EmailVerificationDone.Description = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationDoneNextButtonText {
result.EmailVerificationDone.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationDoneCancelButtonText {
result.EmailVerificationDone.CancelButtonText = text.Text
}
if text.Key == domain.LoginKeyEmailVerificationDoneLoginButtonText {
result.EmailVerificationDone.LoginButtonText = text.Text
}
}
func initializeUserKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitializeUserTitle {
result.InitUser.Title = text.Text
}
if text.Key == domain.LoginKeyInitializeUserDescription {
result.InitUser.Description = text.Text
}
if text.Key == domain.LoginKeyInitializeUserCodeLabel {
result.InitUser.CodeLabel = text.Text
}
if text.Key == domain.LoginKeyInitializeUserNewPasswordLabel {
result.InitUser.NewPasswordLabel = text.Text
}
if text.Key == domain.LoginKeyInitializeUserNewPasswordConfirmLabel {
result.InitUser.NewPasswordConfirmLabel = text.Text
}
if text.Key == domain.LoginKeyInitializeUserResendButtonText {
result.InitUser.ResendButtonText = text.Text
}
if text.Key == domain.LoginKeyInitializeUserNextButtonText {
result.InitUser.NextButtonText = text.Text
}
}
func initializeUserDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitUserDoneTitle {
result.InitUserDone.Title = text.Text
}
if text.Key == domain.LoginKeyInitUserDoneDescription {
result.InitUserDone.Description = text.Text
}
if text.Key == domain.LoginKeyInitUserDoneCancelButtonText {
result.InitUserDone.CancelButtonText = text.Text
}
if text.Key == domain.LoginKeyInitUserDoneNextButtonText {
result.InitUserDone.NextButtonText = text.Text
}
}
func initMFAPromptKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitMFAPromptTitle {
result.InitMFAPrompt.Title = text.Text
}
if text.Key == domain.LoginKeyInitMFAPromptDescription {
result.InitMFAPrompt.Description = text.Text
}
if text.Key == domain.LoginKeyInitMFAPromptOTPOption {
result.InitMFAPrompt.Provider0 = text.Text
}
if text.Key == domain.LoginKeyInitMFAPromptU2FOption {
result.InitMFAPrompt.Provider1 = text.Text
}
if text.Key == domain.LoginKeyInitMFAPromptSkipButtonText {
result.InitMFAPrompt.SkipButtonText = text.Text
}
if text.Key == domain.LoginKeyInitMFAPromptNextButtonText {
result.InitMFAPrompt.NextButtonText = text.Text
}
}
func initMFAOTPKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitMFAOTPTitle {
result.InitMFAOTP.Title = text.Text
}
if text.Key == domain.LoginKeyInitMFAOTPDescription {
result.InitMFAOTP.Description = text.Text
}
if text.Key == domain.LoginKeyInitMFAOTPDescriptionOTP {
result.InitMFAOTP.OTPDescription = text.Text
}
if text.Key == domain.LoginKeyInitMFAOTPCodeLabel {
result.InitMFAOTP.CodeLabel = text.Text
}
if text.Key == domain.LoginKeyInitMFAOTPSecretLabel {
result.InitMFAOTP.SecretLabel = text.Text
}
if text.Key == domain.LoginKeyInitMFAOTPNextButtonText {
result.InitMFAOTP.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyInitMFAOTPCancelButtonText {
result.InitMFAOTP.CancelButtonText = text.Text
}
}
func initMFAU2FKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitMFAU2FTitle {
result.InitMFAU2F.Title = text.Text
}
if text.Key == domain.LoginKeyInitMFAU2FDescription {
result.InitMFAU2F.Description = text.Text
}
if text.Key == domain.LoginKeyInitMFAU2FTokenNameLabel {
result.InitMFAU2F.TokenNameLabel = text.Text
}
if text.Key == domain.LoginKeyInitMFAU2FRegisterTokenButtonText {
result.InitMFAU2F.RegisterTokenButtonText = text.Text
}
if text.Key == domain.LoginKeyInitMFAU2FNotSupported {
result.InitMFAU2F.NotSupported = text.Text
}
if text.Key == domain.LoginKeyInitMFAU2FErrorRetry {
result.InitMFAU2F.ErrorRetry = text.Text
}
}
func initMFADoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyInitMFADoneTitle {
result.InitMFADone.Title = text.Text
}
if text.Key == domain.LoginKeyInitMFADoneDescription {
result.InitMFADone.Description = text.Text
}
if text.Key == domain.LoginKeyInitMFADoneCancelButtonText {
result.InitMFADone.CancelButtonText = text.Text
}
if text.Key == domain.LoginKeyInitMFADoneNextButtonText {
result.InitMFADone.NextButtonText = text.Text
}
}
func mfaProvidersKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyMFAProvidersChooseOther {
result.MFAProvider.ChooseOther = text.Text
}
if text.Key == domain.LoginKeyMFAProvidersOTP {
result.MFAProvider.Provider0 = text.Text
}
if text.Key == domain.LoginKeyMFAProvidersU2F {
result.MFAProvider.Provider1 = text.Text
}
}
func verifyMFAOTPKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyVerifyMFAOTPTitle {
result.VerifyMFAOTP.Title = text.Text
}
if text.Key == domain.LoginKeyVerifyMFAOTPDescription {
result.VerifyMFAOTP.Description = text.Text
}
if text.Key == domain.LoginKeyVerifyMFAOTPCodeLabel {
result.VerifyMFAOTP.CodeLabel = text.Text
}
if text.Key == domain.LoginKeyVerifyMFAOTPNextButtonText {
result.VerifyMFAOTP.NextButtonText = text.Text
}
}
func verifyMFAU2FKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyVerifyMFAU2FTitle {
result.VerifyMFAU2F.Title = text.Text
}
if text.Key == domain.LoginKeyVerifyMFAU2FDescription {
result.VerifyMFAU2F.Description = text.Text
}
if text.Key == domain.LoginKeyVerifyMFAU2FValidateTokenText {
result.VerifyMFAU2F.ValidateTokenButtonText = text.Text
}
if text.Key == domain.LoginKeyVerifyMFAU2FNotSupported {
result.VerifyMFAU2F.NotSupported = text.Text
}
if text.Key == domain.LoginKeyVerifyMFAU2FErrorRetry {
result.VerifyMFAU2F.ErrorRetry = text.Text
}
}
func passwordlessKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordlessTitle {
result.Passwordless.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordlessDescription {
result.Passwordless.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordlessLoginWithPwButtonText {
result.Passwordless.LoginWithPwButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordlessValidateTokenButtonText {
result.Passwordless.ValidateTokenButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordlessNotSupported {
result.Passwordless.NotSupported = text.Text
}
if text.Key == domain.LoginKeyPasswordlessErrorRetry {
result.Passwordless.ErrorRetry = text.Text
}
}
func passwordlessPromptKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordlessPromptTitle {
result.PasswordlessPrompt.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordlessPromptDescription {
result.PasswordlessPrompt.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordlessPromptDescriptionInit {
result.PasswordlessPrompt.DescriptionInit = text.Text
}
if text.Key == domain.LoginKeyPasswordlessPromptPasswordlessButtonText {
result.PasswordlessPrompt.PasswordlessButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordlessPromptNextButtonText {
result.PasswordlessPrompt.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordlessPromptSkipButtonText {
result.PasswordlessPrompt.SkipButtonText = text.Text
}
}
func passwordlessRegistrationKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordlessRegistrationTitle {
result.PasswordlessRegistration.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationDescription {
result.PasswordlessRegistration.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationRegisterTokenButtonText {
result.PasswordlessRegistration.RegisterTokenButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationTokenNameLabel {
result.PasswordlessRegistration.TokenNameLabel = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationNotSupported {
result.PasswordlessRegistration.NotSupported = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationErrorRetry {
result.PasswordlessRegistration.ErrorRetry = text.Text
}
}
func passwordlessRegistrationDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordlessRegistrationDoneTitle {
result.PasswordlessRegistrationDone.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationDoneDescription {
result.PasswordlessRegistrationDone.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationDoneDescriptionClose {
result.PasswordlessRegistrationDone.DescriptionClose = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationDoneNextButtonText {
result.PasswordlessRegistrationDone.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordlessRegistrationDoneCancelButtonText {
result.PasswordlessRegistrationDone.CancelButtonText = text.Text
}
}
func passwordChangeKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordChangeTitle {
result.PasswordChange.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeDescription {
result.PasswordChange.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeOldPasswordLabel {
result.PasswordChange.OldPasswordLabel = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeNewPasswordLabel {
result.PasswordChange.NewPasswordLabel = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeNewPasswordConfirmLabel {
result.PasswordChange.NewPasswordConfirmLabel = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeCancelButtonText {
result.PasswordChange.CancelButtonText = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeNextButtonText {
result.PasswordChange.NextButtonText = text.Text
}
}
func passwordChangeDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordChangeDoneTitle {
result.PasswordChangeDone.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeDoneDescription {
result.PasswordChangeDone.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordChangeDoneNextButtonText {
result.PasswordChangeDone.NextButtonText = text.Text
}
}
func passwordResetDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyPasswordResetDoneTitle {
result.PasswordResetDone.Title = text.Text
}
if text.Key == domain.LoginKeyPasswordResetDoneDescription {
result.PasswordResetDone.Description = text.Text
}
if text.Key == domain.LoginKeyPasswordResetDoneNextButtonText {
result.PasswordResetDone.NextButtonText = text.Text
}
}
func registrationOptionKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyRegistrationOptionTitle {
result.RegisterOption.Title = text.Text
}
if text.Key == domain.LoginKeyRegistrationOptionDescription {
result.RegisterOption.Description = text.Text
}
if text.Key == domain.LoginKeyRegistrationOptionExternalLoginDescription {
result.RegisterOption.ExternalLoginDescription = text.Text
}
if text.Key == domain.LoginKeyRegistrationOptionUserNameButtonText {
result.RegisterOption.RegisterUsernamePasswordButtonText = text.Text
}
}
func registrationUserKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyRegistrationUserTitle {
result.RegistrationUser.Title = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserDescription {
result.RegistrationUser.Description = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserDescriptionOrgRegister {
result.RegistrationUser.DescriptionOrgRegister = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserFirstnameLabel {
result.RegistrationUser.FirstnameLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserLastnameLabel {
result.RegistrationUser.LastnameLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserEmailLabel {
result.RegistrationUser.EmailLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserUsernameLabel {
result.RegistrationUser.UsernameLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserLanguageLabel {
result.RegistrationUser.LanguageLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserGenderLabel {
result.RegistrationUser.GenderLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserPasswordLabel {
result.RegistrationUser.PasswordLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserPasswordConfirmLabel {
result.RegistrationUser.PasswordConfirmLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserTOSAndPrivacyLabel {
result.RegistrationUser.TOSAndPrivacyLabel = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserTOSConfirm {
result.RegistrationUser.TOSConfirm = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserTOSLinkText {
result.RegistrationUser.TOSLinkText = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserTOSConfirmAnd {
result.RegistrationUser.TOSConfirmAnd = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserPrivacyLinkText {
result.RegistrationUser.PrivacyLinkText = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserNextButtonText {
result.RegistrationUser.NextButtonText = text.Text
}
if text.Key == domain.LoginKeyRegistrationUserBackButtonText {
result.RegistrationUser.BackButtonText = text.Text
}
}
func registrationOrgKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyRegisterOrgTitle {
result.RegistrationOrg.Title = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgDescription {
result.RegistrationOrg.Description = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgOrgNameLabel {
result.RegistrationOrg.OrgNameLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgFirstnameLabel {
result.RegistrationOrg.FirstnameLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgLastnameLabel {
result.RegistrationOrg.LastnameLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgUsernameLabel {
result.RegistrationOrg.UsernameLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgEmailLabel {
result.RegistrationOrg.EmailLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgPasswordLabel {
result.RegistrationOrg.PasswordLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgPasswordConfirmLabel {
result.RegistrationOrg.PasswordConfirmLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgTOSAndPrivacyLabel {
result.RegistrationOrg.TOSAndPrivacyLabel = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgTOSConfirm {
result.RegistrationOrg.TOSConfirm = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgTOSLinkText {
result.RegistrationOrg.TOSLinkText = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgTosConfirmAnd {
result.RegistrationOrg.TOSConfirmAnd = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgPrivacyLinkText {
result.RegistrationOrg.PrivacyLinkText = text.Text
}
if text.Key == domain.LoginKeyRegisterOrgSaveButtonText {
result.RegistrationOrg.SaveButtonText = text.Text
}
}
func linkingUserKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyLinkingUserDoneTitle {
result.LinkingUsersDone.Title = text.Text
}
if text.Key == domain.LoginKeyLinkingUserDoneDescription {
result.LinkingUsersDone.Description = text.Text
}
if text.Key == domain.LoginKeyLinkingUserDoneCancelButtonText {
result.LinkingUsersDone.CancelButtonText = text.Text
}
if text.Key == domain.LoginKeyLinkingUserDoneNextButtonText {
result.LinkingUsersDone.NextButtonText = text.Text
}
}
func externalUserNotFoundKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyExternalNotFoundTitle {
result.ExternalNotFoundOption.Title = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundDescription {
result.ExternalNotFoundOption.Description = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundLinkButtonText {
result.ExternalNotFoundOption.LinkButtonText = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundAutoRegisterButtonText {
result.ExternalNotFoundOption.AutoRegisterButtonText = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundTOSAndPrivacyLabel {
result.ExternalNotFoundOption.TOSAndPrivacyLabel = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundTOSConfirm {
result.ExternalNotFoundOption.TOSConfirm = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundTOSLinkText {
result.ExternalNotFoundOption.TOSLinkText = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundTOSConfirmAnd {
result.ExternalNotFoundOption.TOSConfirmAnd = text.Text
}
if text.Key == domain.LoginKeyExternalNotFoundPrivacyLinkText {
result.ExternalNotFoundOption.PrivacyLinkText = text.Text
}
}
func successLoginKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeySuccessLoginTitle {
result.LoginSuccess.Title = text.Text
}
if text.Key == domain.LoginKeySuccessLoginAutoRedirectDescription {
result.LoginSuccess.AutoRedirectDescription = text.Text
}
if text.Key == domain.LoginKeySuccessLoginRedirectedDescription {
result.LoginSuccess.RedirectedDescription = text.Text
}
if text.Key == domain.LoginKeySuccessLoginNextButtonText {
result.LoginSuccess.NextButtonText = text.Text
}
}
func logoutDoneKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyLogoutDoneTitle {
result.LogoutDone.Title = text.Text
}
if text.Key == domain.LoginKeyLogoutDoneDescription {
result.LogoutDone.Description = text.Text
}
if text.Key == domain.LoginKeyLogoutDoneLoginButtonText {
result.LogoutDone.LoginButtonText = text.Text
}
}
func footerKeyToDomain(text *CustomTextView, result *domain.CustomLoginText) {
if text.Key == domain.LoginKeyFooterTOS {
result.Footer.TOS = text.Text
}
if text.Key == domain.LoginKeyFooterPrivacyPolicy {
result.Footer.PrivacyPolicy = text.Text
}
if text.Key == domain.LoginKeyFooterHelp {
result.Footer.Help = text.Text
}
}

View File

@@ -1,65 +0,0 @@
package model
import (
"github.com/caos/zitadel/internal/domain"
iam_model "github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/view/repository"
)
type CustomTextSearchRequest iam_model.CustomTextSearchRequest
type CustomTextSearchQuery iam_model.CustomTextSearchQuery
type CustomTextSearchKey iam_model.CustomTextSearchKey
func (req CustomTextSearchRequest) GetLimit() uint64 {
return req.Limit
}
func (req CustomTextSearchRequest) GetOffset() uint64 {
return req.Offset
}
func (req CustomTextSearchRequest) GetSortingColumn() repository.ColumnKey {
if req.SortingColumn == iam_model.CustomTextSearchKeyUnspecified {
return nil
}
return CustomTextSearchKey(req.SortingColumn)
}
func (req CustomTextSearchRequest) GetAsc() bool {
return req.Asc
}
func (req CustomTextSearchRequest) GetQueries() []repository.SearchQuery {
result := make([]repository.SearchQuery, len(req.Queries))
for i, q := range req.Queries {
result[i] = CustomTextSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
}
return result
}
func (req CustomTextSearchQuery) GetKey() repository.ColumnKey {
return CustomTextSearchKey(req.Key)
}
func (req CustomTextSearchQuery) GetMethod() domain.SearchMethod {
return req.Method
}
func (req CustomTextSearchQuery) GetValue() interface{} {
return req.Value
}
func (key CustomTextSearchKey) ToColumnName() string {
switch iam_model.CustomTextSearchKey(key) {
case iam_model.CustomTextSearchKeyAggregateID:
return CustomTextKeyAggregateID
case iam_model.CustomTextSearchKeyTemplate:
return CustomTextKeyTemplate
case iam_model.CustomTextSearchKeyLanguage:
return CustomTextKeyLanguage
case iam_model.CustomTextSearchKeyKey:
return CustomTextKeyKey
default:
return ""
}
}

View File

@@ -1,95 +0,0 @@
package model
import (
"encoding/json"
"time"
"github.com/caos/logging"
"github.com/lib/pq"
"github.com/caos/zitadel/internal/domain"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/model"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
)
const (
IAMMemberKeyUserID = "user_id"
IAMMemberKeyIamID = "iam_id"
IAMMemberKeyUserName = "user_name"
IAMMemberKeyEmail = "email"
IAMMemberKeyFirstName = "first_name"
IAMMemberKeyLastName = "last_name"
)
type IAMMemberView struct {
UserID string `json:"userId" gorm:"column:user_id;primary_key"`
IAMID string `json:"-" gorm:"column:iam_id"`
UserName string `json:"-" gorm:"column:user_name"`
Email string `json:"-" gorm:"column:email_address"`
FirstName string `json:"-" gorm:"column:first_name"`
LastName string `json:"-" gorm:"column:last_name"`
DisplayName string `json:"-" gorm:"column:display_name"`
Roles pq.StringArray `json:"roles" gorm:"column:roles"`
Sequence uint64 `json:"-" gorm:"column:sequence"`
PreferredLoginName string `json:"-" gorm:"column:preferred_login_name"`
AvatarKey string `json:"-" gorm:"column:avatar_key"`
UserResourceOwner string `json:"-" gorm:"column:user_resource_owner"`
CreationDate time.Time `json:"-" gorm:"column:creation_date"`
ChangeDate time.Time `json:"-" gorm:"column:change_date"`
}
func IAMMemberToModel(member *IAMMemberView, prefixAvatarURL string) *model.IAMMemberView {
return &model.IAMMemberView{
UserID: member.UserID,
IAMID: member.IAMID,
UserName: member.UserName,
Email: member.Email,
FirstName: member.FirstName,
LastName: member.LastName,
DisplayName: member.DisplayName,
PreferredLoginName: member.PreferredLoginName,
AvatarURL: domain.AvatarURL(prefixAvatarURL, member.UserResourceOwner, member.AvatarKey),
UserResourceOwner: member.UserResourceOwner,
Roles: member.Roles,
Sequence: member.Sequence,
CreationDate: member.CreationDate,
ChangeDate: member.ChangeDate,
}
}
func IAMMembersToModel(roles []*IAMMemberView, prefixAvatarURL string) []*model.IAMMemberView {
result := make([]*model.IAMMemberView, len(roles))
for i, r := range roles {
result[i] = IAMMemberToModel(r, prefixAvatarURL)
}
return result
}
func (r *IAMMemberView) AppendEvent(event *models.Event) (err error) {
r.Sequence = event.Sequence
r.ChangeDate = event.CreationDate
switch event.Type {
case es_model.IAMMemberAdded:
r.setRootData(event)
r.CreationDate = event.CreationDate
err = r.SetData(event)
case es_model.IAMMemberChanged:
err = r.SetData(event)
}
return err
}
func (r *IAMMemberView) setRootData(event *models.Event) {
r.IAMID = event.AggregateID
}
func (r *IAMMemberView) SetData(event *models.Event) error {
if err := json.Unmarshal(event.Data, r); err != nil {
logging.Log("EVEN-Psl89").WithError(err).Error("could not unmarshal event data")
return caos_errs.ThrowInternal(err, "MODEL-lub6s", "Could not unmarshal data")
}
return nil
}

View File

@@ -1,69 +0,0 @@
package model
import (
"github.com/caos/zitadel/internal/domain"
iam_model "github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/view/repository"
)
type IAMMemberSearchRequest iam_model.IAMMemberSearchRequest
type IAMMemberSearchQuery iam_model.IAMMemberSearchQuery
type IAMMemberSearchKey iam_model.IAMMemberSearchKey
func (req IAMMemberSearchRequest) GetLimit() uint64 {
return req.Limit
}
func (req IAMMemberSearchRequest) GetOffset() uint64 {
return req.Offset
}
func (req IAMMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
if req.SortingColumn == iam_model.IAMMemberSearchKeyUnspecified {
return nil
}
return IAMMemberSearchKey(req.SortingColumn)
}
func (req IAMMemberSearchRequest) GetAsc() bool {
return req.Asc
}
func (req IAMMemberSearchRequest) GetQueries() []repository.SearchQuery {
result := make([]repository.SearchQuery, len(req.Queries))
for i, q := range req.Queries {
result[i] = IAMMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
}
return result
}
func (req IAMMemberSearchQuery) GetKey() repository.ColumnKey {
return IAMMemberSearchKey(req.Key)
}
func (req IAMMemberSearchQuery) GetMethod() domain.SearchMethod {
return req.Method
}
func (req IAMMemberSearchQuery) GetValue() interface{} {
return req.Value
}
func (key IAMMemberSearchKey) ToColumnName() string {
switch iam_model.IAMMemberSearchKey(key) {
case iam_model.IAMMemberSearchKeyEmail:
return IAMMemberKeyEmail
case iam_model.IAMMemberSearchKeyFirstName:
return IAMMemberKeyFirstName
case iam_model.IAMMemberSearchKeyLastName:
return IAMMemberKeyLastName
case iam_model.IAMMemberSearchKeyUserName:
return IAMMemberKeyUserName
case iam_model.IAMMemberSearchKeyUserID:
return IAMMemberKeyUserID
case iam_model.IAMMemberSearchKeyIamID:
return IAMMemberKeyIamID
default:
return ""
}
}

View File

@@ -5,12 +5,10 @@ import (
"time"
"github.com/caos/zitadel/internal/crypto"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/repository/instance"
"github.com/caos/zitadel/internal/repository/org"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
"github.com/caos/logging"
"github.com/lib/pq"
@@ -87,34 +85,26 @@ func IDPConfigViewToModel(idp *IDPConfigView) *model.IDPConfigView {
return view
}
func IdpConfigViewsToModel(idps []*IDPConfigView) []*model.IDPConfigView {
result := make([]*model.IDPConfigView, len(idps))
for i, idp := range idps {
result[i] = IDPConfigViewToModel(idp)
}
return result
}
func (i *IDPConfigView) AppendEvent(providerType model.IDPProviderType, event *models.Event) (err error) {
i.Sequence = event.Sequence
i.ChangeDate = event.CreationDate
switch event.Type {
case es_model.IDPConfigAdded, org_es_model.IDPConfigAdded:
switch eventstore.EventType(event.Type) {
case instance.IDPConfigAddedEventType, org.IDPConfigAddedEventType:
i.setRootData(event)
i.CreationDate = event.CreationDate
i.IDPProviderType = int32(providerType)
err = i.SetData(event)
case es_model.OIDCIDPConfigAdded, org_es_model.OIDCIDPConfigAdded:
case instance.IDPOIDCConfigAddedEventType, org.IDPOIDCConfigAddedEventType:
i.IsOIDC = true
err = i.SetData(event)
case es_model.OIDCIDPConfigChanged, org_es_model.OIDCIDPConfigChanged,
es_model.IDPConfigChanged, org_es_model.IDPConfigChanged,
models.EventType(org.IDPJWTConfigAddedEventType), models.EventType(instance.IDPJWTConfigAddedEventType),
models.EventType(org.IDPJWTConfigChangedEventType), models.EventType(instance.IDPJWTConfigChangedEventType):
case instance.IDPOIDCConfigChangedEventType, org.IDPOIDCConfigChangedEventType,
instance.IDPConfigChangedEventType, org.IDPConfigChangedEventType,
org.IDPJWTConfigAddedEventType, instance.IDPJWTConfigAddedEventType,
org.IDPJWTConfigChangedEventType, instance.IDPJWTConfigChangedEventType:
err = i.SetData(event)
case es_model.IDPConfigDeactivated, org_es_model.IDPConfigDeactivated:
case instance.IDPConfigDeactivatedEventType, org.IDPConfigDeactivatedEventType:
i.IDPState = int32(model.IDPConfigStateInactive)
case es_model.IDPConfigReactivated, org_es_model.IDPConfigReactivated:
case instance.IDPConfigReactivatedEventType, org.IDPConfigReactivatedEventType:
i.IDPState = int32(model.IDPConfigStateActive)
}
return err
@@ -127,7 +117,7 @@ func (r *IDPConfigView) setRootData(event *models.Event) {
func (r *IDPConfigView) SetData(event *models.Event) error {
if err := json.Unmarshal(event.Data, r); err != nil {
logging.Log("EVEN-Smkld").WithError(err).Error("could not unmarshal event data")
logging.New().WithError(err).Error("could not unmarshal event data")
return caos_errs.ThrowInternal(err, "MODEL-lub6s", "Could not unmarshal data")
}
return nil

View File

@@ -4,15 +4,14 @@ import (
"encoding/json"
"time"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
"github.com/caos/logging"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/repository/instance"
"github.com/caos/zitadel/internal/repository/org"
)
const (
@@ -38,21 +37,6 @@ type IDPProviderView struct {
InstanceID string `json:"instanceID" gorm:"column:instance_id"`
}
func IDPProviderViewFromModel(provider *model.IDPProviderView) *IDPProviderView {
return &IDPProviderView{
AggregateID: provider.AggregateID,
Sequence: provider.Sequence,
CreationDate: provider.CreationDate,
ChangeDate: provider.ChangeDate,
Name: provider.Name,
StylingType: int32(provider.StylingType),
IDPConfigID: provider.IDPConfigID,
IDPConfigType: int32(provider.IDPConfigType),
IDPProviderType: int32(provider.IDPProviderType),
IDPState: int32(provider.IDPState),
}
}
func IDPProviderViewToModel(provider *IDPProviderView) *model.IDPProviderView {
return &model.IDPProviderView{
AggregateID: provider.AggregateID,
@@ -79,8 +63,9 @@ func IDPProviderViewsToModel(providers []*IDPProviderView) []*model.IDPProviderV
func (i *IDPProviderView) AppendEvent(event *models.Event) (err error) {
i.Sequence = event.Sequence
i.ChangeDate = event.CreationDate
switch event.Type {
case es_model.LoginPolicyIDPProviderAdded, org_es_model.LoginPolicyIDPProviderAdded:
switch eventstore.EventType(event.Type) {
case instance.LoginPolicyIDPProviderAddedEventType,
org.LoginPolicyIDPProviderAddedEventType:
i.setRootData(event)
i.CreationDate = event.CreationDate
err = i.SetData(event)
@@ -95,7 +80,7 @@ func (r *IDPProviderView) setRootData(event *models.Event) {
func (r *IDPProviderView) SetData(event *models.Event) error {
if err := json.Unmarshal(event.Data, r); err != nil {
logging.Log("EVEN-Lso0d").WithError(err).Error("could not unmarshal event data")
logging.New().WithError(err).Error("could not unmarshal event data")
return caos_errs.ThrowInternal(err, "MODEL-Hs8uf", "Could not unmarshal data")
}
return nil

View File

@@ -4,16 +4,14 @@ import (
"encoding/json"
"time"
"github.com/caos/zitadel/internal/domain"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
"github.com/caos/logging"
"github.com/caos/zitadel/internal/domain"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/repository/instance"
"github.com/caos/zitadel/internal/repository/org"
)
const (
@@ -84,101 +82,85 @@ func (p *LabelPolicyView) ToDomain() *domain.LabelPolicy {
}
}
func LabelPolicyViewToModel(policy *LabelPolicyView) *model.LabelPolicyView {
return &model.LabelPolicyView{
AggregateID: policy.AggregateID,
Sequence: policy.Sequence,
CreationDate: policy.CreationDate,
ChangeDate: policy.ChangeDate,
PrimaryColor: policy.PrimaryColor,
BackgroundColor: policy.BackgroundColor,
WarnColor: policy.WarnColor,
FontColor: policy.FontColor,
LogoURL: policy.LogoURL,
IconURL: policy.IconURL,
PrimaryColorDark: policy.PrimaryColorDark,
BackgroundColorDark: policy.BackgroundColorDark,
WarnColorDark: policy.WarnColorDark,
FontColorDark: policy.FontColorDark,
LogoDarkURL: policy.LogoDarkURL,
IconDarkURL: policy.IconDarkURL,
FontURL: policy.FontURL,
HideLoginNameSuffix: policy.HideLoginNameSuffix,
ErrorMsgPopup: policy.ErrorMsgPopup,
DisableWatermark: policy.DisableWatermark,
Default: policy.Default,
}
}
func (i *LabelPolicyView) AppendEvent(event *models.Event) (err error) {
asset := &AssetView{}
i.Sequence = event.Sequence
i.ChangeDate = event.CreationDate
switch event.Type {
case es_model.LabelPolicyAdded, org_es_model.LabelPolicyAdded:
switch eventstore.EventType(event.Type) {
case instance.LabelPolicyAddedEventType,
org.LabelPolicyAddedEventType:
i.setRootData(event)
i.CreationDate = event.CreationDate
i.State = int32(domain.LabelPolicyStatePreview)
err = i.SetData(event)
case es_model.LabelPolicyChanged, org_es_model.LabelPolicyChanged:
case instance.LabelPolicyChangedEventType,
org.LabelPolicyChangedEventType:
err = i.SetData(event)
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyLogoAdded, org_es_model.LabelPolicyLogoAdded:
case instance.LabelPolicyLogoAddedEventType,
org.LabelPolicyLogoAddedEventType:
err = asset.SetData(event)
if err != nil {
return err
}
i.LogoURL = asset.AssetURL
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyLogoRemoved, org_es_model.LabelPolicyLogoRemoved:
case instance.LabelPolicyLogoRemovedEventType,
org.LabelPolicyLogoRemovedEventType:
i.LogoURL = ""
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyIconAdded, org_es_model.LabelPolicyIconAdded:
case instance.LabelPolicyIconAddedEventType,
org.LabelPolicyIconAddedEventType:
err = asset.SetData(event)
if err != nil {
return err
}
i.IconURL = asset.AssetURL
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyIconRemoved, org_es_model.LabelPolicyIconRemoved:
case instance.LabelPolicyIconRemovedEventType,
org.LabelPolicyIconRemovedEventType:
i.IconURL = ""
case es_model.LabelPolicyLogoDarkAdded, org_es_model.LabelPolicyLogoDarkAdded:
case instance.LabelPolicyLogoDarkAddedEventType,
org.LabelPolicyLogoDarkAddedEventType:
err = asset.SetData(event)
if err != nil {
return err
}
i.LogoDarkURL = asset.AssetURL
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyLogoDarkRemoved, org_es_model.LabelPolicyLogoDarkRemoved:
case instance.LabelPolicyLogoDarkRemovedEventType,
org.LabelPolicyLogoDarkRemovedEventType:
i.LogoDarkURL = ""
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyIconDarkAdded, org_es_model.LabelPolicyIconDarkAdded:
case instance.LabelPolicyIconDarkAddedEventType,
org.LabelPolicyIconDarkAddedEventType:
err = asset.SetData(event)
if err != nil {
return err
}
i.IconDarkURL = asset.AssetURL
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyIconDarkRemoved, org_es_model.LabelPolicyIconDarkRemoved:
case instance.LabelPolicyIconDarkRemovedEventType,
org.LabelPolicyIconDarkRemovedEventType:
i.IconDarkURL = ""
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyFontAdded, org_es_model.LabelPolicyFontAdded:
case instance.LabelPolicyFontAddedEventType,
org.LabelPolicyFontAddedEventType:
err = asset.SetData(event)
if err != nil {
return err
}
i.FontURL = asset.AssetURL
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyFontRemoved, org_es_model.LabelPolicyFontRemoved:
case instance.LabelPolicyFontRemovedEventType,
org.LabelPolicyFontRemovedEventType:
i.FontURL = ""
i.State = int32(domain.LabelPolicyStatePreview)
case es_model.LabelPolicyActivated, org_es_model.LabelPolicyActivated:
case instance.LabelPolicyActivatedEventType,
org.LabelPolicyActivatedEventType:
i.State = int32(domain.LabelPolicyStateActive)
case es_model.LabelPolicyAssetsRemoved, org_es_model.LabelPolicyAssetsRemoved:
case instance.LabelPolicyAssetsRemovedEventType,
org.LabelPolicyAssetsRemovedEventType:
i.LogoURL = ""
i.IconURL = ""
i.LogoDarkURL = ""

View File

@@ -4,15 +4,15 @@ import (
"encoding/json"
"time"
org_es_model "github.com/caos/zitadel/internal/org/repository/eventsourcing/model"
"github.com/caos/zitadel/internal/query"
es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
"github.com/caos/logging"
caos_errs "github.com/caos/zitadel/internal/errors"
"github.com/caos/zitadel/internal/eventstore"
"github.com/caos/zitadel/internal/eventstore/v1/models"
"github.com/caos/zitadel/internal/iam/model"
"github.com/caos/zitadel/internal/query"
"github.com/caos/zitadel/internal/repository/instance"
"github.com/caos/zitadel/internal/repository/org"
)
const (
@@ -53,12 +53,14 @@ func PasswordComplexityViewToModel(policy *query.PasswordComplexityPolicy) *mode
func (i *PasswordComplexityPolicyView) AppendEvent(event *models.Event) (err error) {
i.Sequence = event.Sequence
i.ChangeDate = event.CreationDate
switch event.Type {
case es_model.PasswordComplexityPolicyAdded, org_es_model.PasswordComplexityPolicyAdded:
switch eventstore.EventType(event.Type) {
case instance.PasswordComplexityPolicyAddedEventType,
org.PasswordComplexityPolicyAddedEventType:
i.setRootData(event)
i.CreationDate = event.CreationDate
err = i.SetData(event)
case es_model.PasswordComplexityPolicyChanged, org_es_model.PasswordComplexityPolicyChanged:
case instance.PasswordComplexityPolicyChangedEventType,
org.PasswordComplexityPolicyChangedEventType:
err = i.SetData(event)
}
return err

View File

@@ -1,21 +0,0 @@
package view
import (
"github.com/caos/zitadel/internal/errors"
es_models "github.com/caos/zitadel/internal/eventstore/v1/models"
iam_es_model "github.com/caos/zitadel/internal/iam/repository/eventsourcing/model"
)
func IAMByIDQuery(id string, latestSequence uint64) (*es_models.SearchQuery, error) {
if id == "" {
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-4ng8sd", "id should be filled")
}
return IAMQuery(latestSequence).
AggregateIDFilter(id), nil
}
func IAMQuery(latestSequence uint64) *es_models.SearchQuery {
return es_models.NewSearchQuery().
AggregateTypeFilter(iam_es_model.IAMAggregate).
LatestSequenceFilter(latestSequence)
}