mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-06 09:27:38 +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
|
||||
`show databases;`
|
||||
|
||||
|
@ -15,6 +15,9 @@ func getUserMethodPermissions(ctx context.Context, t TokenVerifier, requiredPerm
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if grant == nil {
|
||||
return context.WithValue(ctx, permissionsKey, []string{}), []string{}, nil
|
||||
}
|
||||
permissions := mapGrantToPermissions(requiredPerm, grant, authConfig)
|
||||
return context.WithValue(ctx, permissionsKey, permissions), permissions, nil
|
||||
}
|
||||
|
@ -47,6 +47,9 @@ func (repo *UserGrantRepo) SearchMyZitadelPermissions(ctx context.Context) ([]st
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if grant == nil {
|
||||
return []string{}, nil
|
||||
}
|
||||
permissions := &grant_model.Permissions{Permissions: []string{}}
|
||||
for _, role := range grant.Roles {
|
||||
roleName, ctxID := auth.SplitPermission(role)
|
||||
|
@ -282,7 +282,7 @@ func InitCodeVerifiedAggregate(aggCreator *es_models.AggregateCreator, existing
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if password != nil {
|
||||
if password != nil && password.Secret != nil {
|
||||
agg, err = agg.AppendEvent(model.UserPasswordChanged, password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -2,6 +2,7 @@ package eventsourcing
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/caos/zitadel/internal/crypto"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@ -756,12 +757,11 @@ func TestInitCodeVerifiedAggregate(t *testing.T) {
|
||||
Profile: &model.Profile{UserName: "UserName"},
|
||||
Email: &model.Email{EmailAddress: "EmailAddress", IsEmailVerified: true},
|
||||
},
|
||||
password: &model.Password{ChangeRequired: false},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
eventLen: 2,
|
||||
eventTypes: []models.EventType{model.UserPasswordChanged, model.InitializedUserCheckSucceeded},
|
||||
eventLen: 1,
|
||||
eventTypes: []models.EventType{model.InitializedUserCheckSucceeded},
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -772,7 +772,7 @@ func TestInitCodeVerifiedAggregate(t *testing.T) {
|
||||
Profile: &model.Profile{UserName: "UserName"},
|
||||
Email: &model.Email{EmailAddress: "EmailAddress"},
|
||||
},
|
||||
password: &model.Password{ChangeRequired: false},
|
||||
password: &model.Password{Secret: &crypto.CryptoValue{}, ChangeRequired: false},
|
||||
aggCreator: models.NewAggregateCreator("Test"),
|
||||
},
|
||||
res: res{
|
||||
|
Loading…
x
Reference in New Issue
Block a user