mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-07 20:47:41 +00:00
fix: Inituser (#386)
* fix: init user only create change pw event if pw set * fix: init user only create change pw event if pw set * fix: tests
This commit is contained in:
parent
c0f85c2733
commit
a5bfd085a1
@ -31,3 +31,4 @@ cockroachdb/cockroach:v19.2.2 start --insecure
|
|||||||
|
|
||||||
#### Should show eventstore, management, admin, auth
|
#### Should show eventstore, management, admin, auth
|
||||||
`show databases;`
|
`show databases;`
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ func getUserMethodPermissions(ctx context.Context, t TokenVerifier, requiredPerm
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
if grant == nil {
|
||||||
|
return context.WithValue(ctx, permissionsKey, []string{}), []string{}, nil
|
||||||
|
}
|
||||||
permissions := mapGrantToPermissions(requiredPerm, grant, authConfig)
|
permissions := mapGrantToPermissions(requiredPerm, grant, authConfig)
|
||||||
return context.WithValue(ctx, permissionsKey, permissions), permissions, nil
|
return context.WithValue(ctx, permissionsKey, permissions), permissions, nil
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ func (repo *UserGrantRepo) SearchMyZitadelPermissions(ctx context.Context) ([]st
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if grant == nil {
|
||||||
|
return []string{}, nil
|
||||||
|
}
|
||||||
permissions := &grant_model.Permissions{Permissions: []string{}}
|
permissions := &grant_model.Permissions{Permissions: []string{}}
|
||||||
for _, role := range grant.Roles {
|
for _, role := range grant.Roles {
|
||||||
roleName, ctxID := auth.SplitPermission(role)
|
roleName, ctxID := auth.SplitPermission(role)
|
||||||
|
@ -282,7 +282,7 @@ func InitCodeVerifiedAggregate(aggCreator *es_models.AggregateCreator, existing
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if password != nil {
|
if password != nil && password.Secret != nil {
|
||||||
agg, err = agg.AppendEvent(model.UserPasswordChanged, password)
|
agg, err = agg.AppendEvent(model.UserPasswordChanged, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -2,6 +2,7 @@ package eventsourcing
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"github.com/caos/zitadel/internal/crypto"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -756,12 +757,11 @@ func TestInitCodeVerifiedAggregate(t *testing.T) {
|
|||||||
Profile: &model.Profile{UserName: "UserName"},
|
Profile: &model.Profile{UserName: "UserName"},
|
||||||
Email: &model.Email{EmailAddress: "EmailAddress", IsEmailVerified: true},
|
Email: &model.Email{EmailAddress: "EmailAddress", IsEmailVerified: true},
|
||||||
},
|
},
|
||||||
password: &model.Password{ChangeRequired: false},
|
|
||||||
aggCreator: models.NewAggregateCreator("Test"),
|
aggCreator: models.NewAggregateCreator("Test"),
|
||||||
},
|
},
|
||||||
res: res{
|
res: res{
|
||||||
eventLen: 2,
|
eventLen: 1,
|
||||||
eventTypes: []models.EventType{model.UserPasswordChanged, model.InitializedUserCheckSucceeded},
|
eventTypes: []models.EventType{model.InitializedUserCheckSucceeded},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -772,7 +772,7 @@ func TestInitCodeVerifiedAggregate(t *testing.T) {
|
|||||||
Profile: &model.Profile{UserName: "UserName"},
|
Profile: &model.Profile{UserName: "UserName"},
|
||||||
Email: &model.Email{EmailAddress: "EmailAddress"},
|
Email: &model.Email{EmailAddress: "EmailAddress"},
|
||||||
},
|
},
|
||||||
password: &model.Password{ChangeRequired: false},
|
password: &model.Password{Secret: &crypto.CryptoValue{}, ChangeRequired: false},
|
||||||
aggCreator: models.NewAggregateCreator("Test"),
|
aggCreator: models.NewAggregateCreator("Test"),
|
||||||
},
|
},
|
||||||
res: res{
|
res: res{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user