mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-16 12:58:00 +00:00
7a6ca24625
* check uniqueness on create and register user * change user email, reserve release unique email * usergrant unique aggregate * usergrant uniqueness * validate UserGrant * fix tests * domain is set on username in all orgs * domain in admin * org domain sql * zitadel domain org name * org domains * org iam policy * default org iam policy * SETUP * load login names * login by login name * login name * fix: merge master * fix: merge master * Update internal/user/repository/eventsourcing/user.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * fix: fix unique domains * fix: rename env variable Co-authored-by: adlerhurst <silvan.reusser@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
52 lines
2.0 KiB
Go
52 lines
2.0 KiB
Go
package eventsourcing
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/caos/zitadel/internal/errors"
|
|
es_models "github.com/caos/zitadel/internal/eventstore/models"
|
|
"github.com/caos/zitadel/internal/policy/model"
|
|
)
|
|
|
|
func PasswordAgePolicyQuery(recourceOwner string, latestSequence uint64) *es_models.SearchQuery {
|
|
return es_models.NewSearchQuery().
|
|
AggregateTypeFilter(model.PasswordAgePolicyAggregate).
|
|
LatestSequenceFilter(latestSequence).
|
|
ResourceOwnerFilter(recourceOwner)
|
|
}
|
|
|
|
func PasswordAgePolicyAggregate(ctx context.Context, aggCreator *es_models.AggregateCreator, policy *PasswordAgePolicy) (*es_models.Aggregate, error) {
|
|
if policy == nil {
|
|
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-1T05i", "existing policy should not be nil")
|
|
}
|
|
return aggCreator.NewAggregate(ctx, policy.AggregateID, model.PasswordAgePolicyAggregate, policyAgeVersion, policy.Sequence)
|
|
}
|
|
|
|
func PasswordAgePolicyCreateAggregate(aggCreator *es_models.AggregateCreator, policy *PasswordAgePolicy) func(ctx context.Context) (*es_models.Aggregate, error) {
|
|
return func(ctx context.Context) (*es_models.Aggregate, error) {
|
|
if policy == nil {
|
|
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-kdie6", "policy should not be nil")
|
|
}
|
|
agg, err := PasswordAgePolicyAggregate(ctx, aggCreator, policy)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return agg.AppendEvent(model.PasswordAgePolicyAdded, policy)
|
|
}
|
|
}
|
|
|
|
func PasswordAgePolicyUpdateAggregate(aggCreator *es_models.AggregateCreator, existing *PasswordAgePolicy, new *PasswordAgePolicy) func(ctx context.Context) (*es_models.Aggregate, error) {
|
|
return func(ctx context.Context) (*es_models.Aggregate, error) {
|
|
if new == nil {
|
|
return nil, errors.ThrowPreconditionFailed(nil, "EVENT-dhr74", "new policy should not be nil")
|
|
}
|
|
agg, err := PasswordAgePolicyAggregate(ctx, aggCreator, existing)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
changes := existing.AgeChanges(new)
|
|
return agg.AppendEvent(model.PasswordAgePolicyChanged, changes)
|
|
}
|
|
}
|