mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-12 11:04:25 +00:00
ed80a8bb1e
* feat(actions): begin api * feat(actions): begin api * api and projections * fix: handle multiple statements for a single event in projections * export func type * fix test * update to new reduce interface * flows in login * feat: jwt idp * feat: command side * feat: add tests * actions and flows * fill idp views with jwt idps and return apis * add jwtEndpoint to jwt idp * begin jwt request handling * add feature * merge * merge * handle jwt idp * cleanup * bug fixes * autoregister * get token from specific header name * fix: proto * fixes * i18n * begin tests * fix and log http proxy * remove docker cache * fixes * usergrants in actions api * tests adn cleanup * cleanup * fix add user grant * set login context * i18n Co-authored-by: fabi <fabienne.gerschwiler@gmail.com>
111 lines
3.0 KiB
Go
111 lines
3.0 KiB
Go
package command
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/caos/zitadel/internal/domain"
|
|
"github.com/caos/zitadel/internal/eventstore"
|
|
"github.com/caos/zitadel/internal/repository/features"
|
|
)
|
|
|
|
type FeaturesWriteModel struct {
|
|
eventstore.WriteModel
|
|
|
|
TierName string
|
|
TierDescription string
|
|
State domain.FeaturesState
|
|
StateDescription string
|
|
AuditLogRetention time.Duration
|
|
LoginPolicyFactors bool
|
|
LoginPolicyIDP bool
|
|
LoginPolicyPasswordless bool
|
|
LoginPolicyRegistration bool
|
|
LoginPolicyUsernameLogin bool
|
|
LoginPolicyPasswordReset bool
|
|
PasswordComplexityPolicy bool
|
|
LabelPolicyPrivateLabel bool
|
|
LabelPolicyWatermark bool
|
|
CustomDomain bool
|
|
PrivacyPolicy bool
|
|
MetadataUser bool
|
|
CustomTextMessage bool
|
|
CustomTextLogin bool
|
|
LockoutPolicy bool
|
|
Actions bool
|
|
}
|
|
|
|
func (wm *FeaturesWriteModel) Reduce() error {
|
|
for _, event := range wm.Events {
|
|
switch e := event.(type) {
|
|
case *features.FeaturesSetEvent:
|
|
if e.TierName != nil {
|
|
wm.TierName = *e.TierName
|
|
}
|
|
if e.TierDescription != nil {
|
|
wm.TierDescription = *e.TierDescription
|
|
}
|
|
wm.State = domain.FeaturesStateActive
|
|
if e.State != nil {
|
|
wm.State = *e.State
|
|
}
|
|
if e.StateDescription != nil {
|
|
wm.StateDescription = *e.StateDescription
|
|
}
|
|
if e.AuditLogRetention != nil {
|
|
wm.AuditLogRetention = *e.AuditLogRetention
|
|
}
|
|
if e.LoginPolicyFactors != nil {
|
|
wm.LoginPolicyFactors = *e.LoginPolicyFactors
|
|
}
|
|
if e.LoginPolicyIDP != nil {
|
|
wm.LoginPolicyIDP = *e.LoginPolicyIDP
|
|
}
|
|
if e.LoginPolicyPasswordless != nil {
|
|
wm.LoginPolicyPasswordless = *e.LoginPolicyPasswordless
|
|
}
|
|
if e.LoginPolicyRegistration != nil {
|
|
wm.LoginPolicyRegistration = *e.LoginPolicyRegistration
|
|
}
|
|
if e.LoginPolicyUsernameLogin != nil {
|
|
wm.LoginPolicyUsernameLogin = *e.LoginPolicyUsernameLogin
|
|
}
|
|
if e.LoginPolicyPasswordReset != nil {
|
|
wm.LoginPolicyPasswordReset = *e.LoginPolicyPasswordReset
|
|
}
|
|
if e.PasswordComplexityPolicy != nil {
|
|
wm.PasswordComplexityPolicy = *e.PasswordComplexityPolicy
|
|
}
|
|
if e.LabelPolicy != nil {
|
|
wm.LabelPolicyPrivateLabel = *e.LabelPolicy
|
|
}
|
|
if e.LabelPolicyPrivateLabel != nil {
|
|
wm.LabelPolicyPrivateLabel = *e.LabelPolicyPrivateLabel
|
|
}
|
|
if e.LabelPolicyWatermark != nil {
|
|
wm.LabelPolicyWatermark = *e.LabelPolicyWatermark
|
|
}
|
|
if e.CustomDomain != nil {
|
|
wm.CustomDomain = *e.CustomDomain
|
|
}
|
|
if e.MetadataUser != nil {
|
|
wm.MetadataUser = *e.MetadataUser
|
|
}
|
|
if e.CustomTextMessage != nil {
|
|
wm.CustomTextMessage = *e.CustomTextMessage
|
|
}
|
|
if e.CustomTextLogin != nil {
|
|
wm.CustomTextLogin = *e.CustomTextLogin
|
|
}
|
|
if e.LockoutPolicy != nil {
|
|
wm.LockoutPolicy = *e.LockoutPolicy
|
|
}
|
|
if e.Actions != nil {
|
|
wm.Actions = *e.Actions
|
|
}
|
|
case *features.FeaturesRemovedEvent:
|
|
wm.State = domain.FeaturesStateRemoved
|
|
}
|
|
}
|
|
return wm.WriteModel.Reduce()
|
|
}
|