mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-11 21:27:42 +00:00
feat: add project creator role on register user (#222)
* feat: add project creator role on register user * fix: better error message * fix: tests
This commit is contained in:
@@ -62,7 +62,7 @@ func precondtion(tx *sql.Tx, aggregate *models.Aggregate) error {
|
||||
}
|
||||
err = aggregate.Precondition.Validation(events...)
|
||||
if err != nil {
|
||||
return caos_errs.ThrowPreconditionFailed(err, "SQL-s6hqU", "validation failed")
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -362,7 +362,7 @@ func Test_precondtion(t *testing.T) {
|
||||
expectBegin(nil).expectFilterEventsLimit(5, 0),
|
||||
},
|
||||
args: args{
|
||||
aggregate: aggregateWithPrecondition(&models.Aggregate{}, models.NewSearchQuery().SetLimit(5), validationFunc(errors.CreateCaosError(nil, "SQL-LBIKm", "err"))),
|
||||
aggregate: aggregateWithPrecondition(&models.Aggregate{}, models.NewSearchQuery().SetLimit(5), validationFunc(errors.ThrowPreconditionFailed(nil, "SQL-LBIKm", "err"))),
|
||||
},
|
||||
isErr: errors.IsPreconditionFailed,
|
||||
},
|
||||
|
@@ -85,7 +85,10 @@ func (a *Aggregate) Validate() error {
|
||||
if a.resourceOwner == "" {
|
||||
return errors.ThrowPreconditionFailed(nil, "MODEL-eBYUW", "resource owner not set")
|
||||
}
|
||||
if a.Precondition != nil && (a.Precondition.Query == nil || a.Precondition.Query.Validate() != nil || a.Precondition.Validation == nil) {
|
||||
if a.Precondition != nil && (a.Precondition.Query == nil || a.Precondition.Validation == nil) {
|
||||
if err := a.Precondition.Query.Validate(); err != nil {
|
||||
return err
|
||||
}
|
||||
return errors.ThrowPreconditionFailed(nil, "MODEL-EEUvA", "invalid precondition")
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user