fix: update profile instead of username. Display p.username (#19621)
* update profile instead of username. Display p.username * Update packages/trpc/server/routers/viewer/organizations/listMembers.handler.ts Co-authored-by: Alex van Andel <me@alexvanandel.com> * Update packages/trpc/server/routers/viewer/organizations/getUser.handler.ts --------- Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
1 parent
dc8be81334
commit
be6f975d34
3 files changed
+14
-2
No files matched your search
@@ -40,6 +40,11 @@ export async function getUserHandler({ input, ctx }: AdminVerifyOptions) {
|
||||
name: true,
|
||||
},
|
||||
},
|
||||
profiles: {
|
||||
select: {
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
// Query on accepted as we don't want the user to be able to get this much info on a user that hasn't accepted the invite
|
||||
@@ -77,6 +82,8 @@ export async function getUserHandler({ input, ctx }: AdminVerifyOptions) {
|
||||
|
||||
const foundUser = {
|
||||
...requestedUser,
|
||||
// Enrich with the users profile for the username or fall back to the username their account was created with.
|
||||
username: requestedUser.profiles[0]?.username || requestedUser.username,
|
||||
teams: teams.map((team) => ({
|
||||
...team.team,
|
||||
accepted: team.accepted,
|
||||
|
||||
@@ -164,6 +164,12 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
select: {
|
||||
id: true,
|
||||
username: true,
|
||||
profiles: {
|
||||
select: {
|
||||
organizationId: true,
|
||||
username: true,
|
||||
},
|
||||
},
|
||||
email: true,
|
||||
avatarUrl: true,
|
||||
timeZone: true,
|
||||
@@ -230,7 +236,7 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
|
||||
|
||||
return {
|
||||
id: user.id,
|
||||
username: user.username,
|
||||
username: user.profiles[0]?.username || user.username,
|
||||
email: user.email,
|
||||
timeZone: user.timeZone,
|
||||
role: membership.role,
|
||||
|
||||
@@ -111,7 +111,6 @@ export const updateUserHandler = async ({ ctx, input }: UpdateUserOptions) => {
|
||||
email: input.email,
|
||||
name: input.name,
|
||||
timeZone: input.timeZone,
|
||||
username: input.username,
|
||||
};
|
||||
|
||||
if (input.avatar && input.avatar.startsWith("data:image/png;base64,")) {
|
||||
|
||||
Reference in new issue
Block a user