From c0b37924c85b8ae9ded7d9061b9f0cef570d57d4 Mon Sep 17 00:00:00 2001 From: Livio Amstutz Date: Fri, 26 Mar 2021 16:29:26 +0100 Subject: [PATCH] fix: backend (#1481) * fix: check ids in proto * fix sign out * improve displayed login name after user selection * fix init user in login * fix init password in login Co-authored-by: fabi --- .../eventsourcing/eventstore/auth_request.go | 6 +++++- internal/repository/user/human.go | 2 +- .../ui/login/static/templates/init_password.html | 12 +++++++----- .../ui/login/static/templates/init_user.html | 16 +++++++++------- proto/zitadel/management.proto | 10 +++++----- 5 files changed, 27 insertions(+), 19 deletions(-) diff --git a/internal/auth/repository/eventsourcing/eventstore/auth_request.go b/internal/auth/repository/eventsourcing/eventstore/auth_request.go index 8cecf0113..da3c3221a 100644 --- a/internal/auth/repository/eventsourcing/eventstore/auth_request.go +++ b/internal/auth/repository/eventsourcing/eventstore/auth_request.go @@ -244,7 +244,11 @@ func (repo *AuthRequestRepo) SelectUser(ctx context.Context, id, userID, userAge if request.RequestedOrgID != "" && request.RequestedOrgID != user.ResourceOwner { return errors.ThrowPreconditionFailed(nil, "EVENT-fJe2a", "Errors.User.NotAllowedOrg") } - request.SetUserInfo(user.ID, user.UserName, user.PreferredLoginName, user.DisplayName, user.ResourceOwner) + username := user.UserName + if request.RequestedOrgID == "" { + username = user.PreferredLoginName + } + request.SetUserInfo(user.ID, username, user.PreferredLoginName, user.DisplayName, user.ResourceOwner) return repo.AuthRequests.UpdateAuthRequest(ctx, request) } diff --git a/internal/repository/user/human.go b/internal/repository/user/human.go index efc18eca0..67ca9a107 100644 --- a/internal/repository/user/human.go +++ b/internal/repository/user/human.go @@ -372,7 +372,7 @@ type HumanSignedOutEvent struct { } func (e *HumanSignedOutEvent) Data() interface{} { - return nil + return e } func (e *HumanSignedOutEvent) UniqueConstraints() []*eventstore.EventUniqueConstraint { diff --git a/internal/ui/login/static/templates/init_password.html b/internal/ui/login/static/templates/init_password.html index 846318088..c3987493b 100644 --- a/internal/ui/login/static/templates/init_password.html +++ b/internal/ui/login/static/templates/init_password.html @@ -36,15 +36,17 @@ {{ template "error-message" .}} - -
+ + + + + - - {{t "Actions.Cancel"}} - + +
diff --git a/internal/ui/login/static/templates/init_user.html b/internal/ui/login/static/templates/init_user.html index a708bea68..2fad59835 100644 --- a/internal/ui/login/static/templates/init_user.html +++ b/internal/ui/login/static/templates/init_user.html @@ -21,9 +21,6 @@ required> - - {{ if not .PasswordSet }}
@@ -43,13 +40,18 @@ {{ template "error-message" .}} -
- - {{t "Actions.Cancel"}} +
+ + + - + + + + +
diff --git a/proto/zitadel/management.proto b/proto/zitadel/management.proto index b271dd3a1..5cbd20073 100644 --- a/proto/zitadel/management.proto +++ b/proto/zitadel/management.proto @@ -827,7 +827,7 @@ service ManagementService { option (zitadel.v1.auth_option) = { permission: "project.role.write" - check_field_name: "Id" + check_field_name: "ProjectId" }; } @@ -840,7 +840,7 @@ service ManagementService { option (zitadel.v1.auth_option) = { permission: "project.role.write" - check_field_name: "Id" + check_field_name: "ProjectId" }; } @@ -852,7 +852,7 @@ service ManagementService { option (zitadel.v1.auth_option) = { permission: "project.role.write" - check_field_name: "Id" + check_field_name: "ProjectId" }; } @@ -864,7 +864,7 @@ service ManagementService { option (zitadel.v1.auth_option) = { permission: "project.role.delete" - check_field_name: "Id" + check_field_name: "ProjectId" }; } @@ -910,7 +910,7 @@ service ManagementService { option (zitadel.v1.auth_option) = { permission: "project.member.write" - check_field_name: "Id" + check_field_name: "ProjectId" }; }