From d5f0c2375afbd355dda1fb1f4b3e8a2e430a5f1a Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Mon, 22 Mar 2021 17:15:24 +0100 Subject: [PATCH] fix: backend bugs (#1453) * fix: add events to query * fix: add events to query * displayname * change email RO Co-authored-by: fabi --- cmd/zitadel/caos_local.sh | 4 ++-- internal/api/grpc/auth/profile_converter.go | 4 +++- internal/api/grpc/management/user.go | 2 +- internal/api/grpc/management/user_converter.go | 7 +++++-- internal/command/user_human_email_model.go | 2 ++ internal/command/user_human_model.go | 2 ++ internal/command/user_human_password_model.go | 2 ++ internal/command/user_human_phone_model.go | 2 ++ 8 files changed, 19 insertions(+), 6 deletions(-) diff --git a/cmd/zitadel/caos_local.sh b/cmd/zitadel/caos_local.sh index 3c323dcb64..30eca3db4e 100755 --- a/cmd/zitadel/caos_local.sh +++ b/cmd/zitadel/caos_local.sh @@ -71,6 +71,6 @@ export ZITADEL_DEFAULT_DOMAIN=localhost #Setup -export ZITADEL_CONSOLE_RESPONSE_TYPE='ID_TOKEN TOKEN' -export ZITADEL_CONSOLE_GRANT_TYPE='IMPLICIT' +export ZITADEL_CONSOLE_RESPONSE_TYPE='AUTHORIZATION_CODE' +export ZITADEL_CONSOLE_GRANT_TYPE='CODE' export ZITADEL_CONSOLE_DEV_MODE=true \ No newline at end of file diff --git a/internal/api/grpc/auth/profile_converter.go b/internal/api/grpc/auth/profile_converter.go index 380f5ca6f9..6c81f5e643 100644 --- a/internal/api/grpc/auth/profile_converter.go +++ b/internal/api/grpc/auth/profile_converter.go @@ -4,10 +4,11 @@ import ( "context" "github.com/caos/logging" + "golang.org/x/text/language" + "github.com/caos/zitadel/internal/api/grpc/user" "github.com/caos/zitadel/internal/domain" "github.com/caos/zitadel/pkg/grpc/auth" - "golang.org/x/text/language" ) func UpdateProfileToDomain(ctx context.Context, profile *auth.UpdateMyProfileRequest) *domain.Profile { @@ -19,6 +20,7 @@ func UpdateProfileToDomain(ctx context.Context, profile *auth.UpdateMyProfileReq FirstName: profile.FirstName, LastName: profile.LastName, NickName: profile.NickName, + DisplayName: profile.DisplayName, PreferredLanguage: lang, Gender: user.GenderToDomain(profile.Gender), } diff --git a/internal/api/grpc/management/user.go b/internal/api/grpc/management/user.go index c8287abe45..ae1e268fbd 100644 --- a/internal/api/grpc/management/user.go +++ b/internal/api/grpc/management/user.go @@ -221,7 +221,7 @@ func (s *Server) GetHumanEmail(ctx context.Context, req *mgmt_pb.GetHumanEmailRe } func (s *Server) UpdateHumanEmail(ctx context.Context, req *mgmt_pb.UpdateHumanEmailRequest) (*mgmt_pb.UpdateHumanEmailResponse, error) { - email, err := s.command.ChangeHumanEmail(ctx, UpdateHumanEmailRequestToDomain(req)) + email, err := s.command.ChangeHumanEmail(ctx, UpdateHumanEmailRequestToDomain(ctx, req)) if err != nil { return nil, err } diff --git a/internal/api/grpc/management/user_converter.go b/internal/api/grpc/management/user_converter.go index 6edcac18ac..e3a0f5bb98 100644 --- a/internal/api/grpc/management/user_converter.go +++ b/internal/api/grpc/management/user_converter.go @@ -91,9 +91,12 @@ func UpdateHumanProfileRequestToDomain(req *mgmt_pb.UpdateHumanProfileRequest) * } } -func UpdateHumanEmailRequestToDomain(req *mgmt_pb.UpdateHumanEmailRequest) *domain.Email { +func UpdateHumanEmailRequestToDomain(ctx context.Context, req *mgmt_pb.UpdateHumanEmailRequest) *domain.Email { return &domain.Email{ - ObjectRoot: models.ObjectRoot{AggregateID: req.UserId}, + ObjectRoot: models.ObjectRoot{ + AggregateID: req.UserId, + ResourceOwner: authz.GetCtxData(ctx).OrgID, + }, EmailAddress: req.Email, IsEmailVerified: req.IsEmailVerified, } diff --git a/internal/command/user_human_email_model.go b/internal/command/user_human_email_model.go index fe54023189..f39816d6d3 100644 --- a/internal/command/user_human_email_model.go +++ b/internal/command/user_human_email_model.go @@ -68,6 +68,8 @@ func (wm *HumanEmailWriteModel) Query() *eventstore.SearchQueryBuilder { AggregateIDs(wm.AggregateID). EventTypes(user.HumanAddedType, user.HumanRegisteredType, + user.HumanInitialCodeAddedType, + user.HumanInitializedCheckSucceededType, user.HumanEmailChangedType, user.HumanEmailCodeAddedType, user.HumanEmailVerifiedType, diff --git a/internal/command/user_human_model.go b/internal/command/user_human_model.go index 0519754802..a1d557243f 100644 --- a/internal/command/user_human_model.go +++ b/internal/command/user_human_model.go @@ -101,6 +101,8 @@ func (wm *HumanWriteModel) Query() *eventstore.SearchQueryBuilder { ResourceOwner(wm.ResourceOwner). EventTypes(user.HumanAddedType, user.HumanRegisteredType, + user.HumanInitialCodeAddedType, + user.HumanInitializedCheckSucceededType, user.UserUserNameChangedType, user.HumanProfileChangedType, user.HumanEmailChangedType, diff --git a/internal/command/user_human_password_model.go b/internal/command/user_human_password_model.go index 13489de543..28261311a2 100644 --- a/internal/command/user_human_password_model.go +++ b/internal/command/user_human_password_model.go @@ -70,6 +70,8 @@ func (wm *HumanPasswordWriteModel) Query() *eventstore.SearchQueryBuilder { AggregateIDs(wm.AggregateID). EventTypes(user.HumanAddedType, user.HumanRegisteredType, + user.HumanInitialCodeAddedType, + user.HumanInitializedCheckSucceededType, user.HumanPasswordChangedType, user.HumanPasswordCodeAddedType, user.HumanEmailVerifiedType, diff --git a/internal/command/user_human_phone_model.go b/internal/command/user_human_phone_model.go index 3c65378f16..84d5d28af8 100644 --- a/internal/command/user_human_phone_model.go +++ b/internal/command/user_human_phone_model.go @@ -79,6 +79,8 @@ func (wm *HumanPhoneWriteModel) Query() *eventstore.SearchQueryBuilder { ResourceOwner(wm.ResourceOwner). EventTypes(user.HumanAddedType, user.HumanRegisteredType, + user.HumanInitialCodeAddedType, + user.HumanInitializedCheckSucceededType, user.HumanPhoneChangedType, user.HumanPhoneVerifiedType, user.HumanPhoneCodeAddedType,