chore(console): remove first and lastName fallback from user (#5629)

* chore(console): remove first and lastName fallback from user

* use display name and ensure it's set without required name fields

* add user type to user grant and memberships responses

* contributor, members

* fix avatar display checks

---------

Co-authored-by: Livio Spring <livio.a@gmail.com>
This commit is contained in:
Max Peintner
2023-04-11 17:56:51 +02:00
committed by GitHub
parent 8bf36301ed
commit 1c1d66cbe8
37 changed files with 218 additions and 114 deletions

View File

@@ -8,6 +8,7 @@ import (
"github.com/zitadel/zitadel/internal/api/authz"
"github.com/zitadel/zitadel/internal/api/call"
"github.com/zitadel/zitadel/internal/domain"
"github.com/zitadel/zitadel/internal/errors"
"github.com/zitadel/zitadel/internal/query/projection"
"github.com/zitadel/zitadel/internal/telemetry/tracing"
@@ -122,10 +123,12 @@ func prepareInstanceMembersQuery(ctx context.Context, db prepareDatabase) (sq.Se
HumanDisplayNameCol.identifier(),
MachineNameCol.identifier(),
HumanAvatarURLCol.identifier(),
UserTypeCol.identifier(),
countColumn.identifier(),
).From(instanceMemberTable.identifier()).
LeftJoin(join(HumanUserIDCol, InstanceMemberUserID)).
LeftJoin(join(MachineUserIDCol, InstanceMemberUserID)).
LeftJoin(join(UserIDCol, InstanceMemberUserID)).
LeftJoin(join(LoginNameUserIDCol, InstanceMemberUserID) + db.Timetravel(call.Took(ctx))).
Where(
sq.Eq{LoginNameIsPrimaryCol.identifier(): true},
@@ -145,6 +148,7 @@ func prepareInstanceMembersQuery(ctx context.Context, db prepareDatabase) (sq.Se
displayName = sql.NullString{}
machineName = sql.NullString{}
avatarURL = sql.NullString{}
userType = sql.NullInt32{}
)
err := rows.Scan(
@@ -161,6 +165,7 @@ func prepareInstanceMembersQuery(ctx context.Context, db prepareDatabase) (sq.Se
&displayName,
&machineName,
&avatarURL,
&userType,
&count,
)
@@ -179,6 +184,7 @@ func prepareInstanceMembersQuery(ctx context.Context, db prepareDatabase) (sq.Se
} else {
member.DisplayName = machineName.String
}
member.UserType = domain.UserType(userType.Int32)
members = append(members, member)
}