diff --git a/next/api/src/controller/user.ts b/next/api/src/controller/user.ts index 5a0c19396..2d2b2b50f 100644 --- a/next/api/src/controller/user.ts +++ b/next/api/src/controller/user.ts @@ -15,7 +15,7 @@ import { import { FindModelPipe, ParseCsvPipe, TrimPipe, ZodValidationPipe } from '@/common/pipe'; import { auth, customerServiceOnly, staffOnly, systemRoleMemberGuard } from '@/middleware'; import { transformToHttpError, User } from '@/model/User'; -import { UserSearchResult } from '@/response/user'; +import { UserResponse } from '@/response/user'; import { getVerifiedPayloadWithSubRequired, processKeys, signPayload } from '@/utils/jwt'; import { withAsyncSpan } from '@/utils/trace'; import { Context } from 'koa'; @@ -71,7 +71,7 @@ const TDSUserSigningKey = process.env.TDS_USER_SIGNING_KEY; export class UserController { @Get() @UseMiddlewares(auth, systemRoleMemberGuard) - @ResponseBody(UserSearchResult) + @ResponseBody(UserResponse) find( @Pagination() [page, pageSize]: [number, number], @Query('id', ParseCsvPipe) ids: string[] | undefined, @@ -102,14 +102,14 @@ export class UserController { @Get('me') @UseMiddlewares(auth) - @ResponseBody(UserSearchResult) + @ResponseBody(UserResponse) getMe(@CurrentUser() currentUser: User) { return currentUser; } @Get(':id') @UseMiddlewares(auth, staffOnly) - @ResponseBody(UserSearchResult) + @ResponseBody(UserResponse) findOne(@Param('id', new FindModelPipe(User)) user: User) { return user; } @@ -173,7 +173,7 @@ export class UserController { @Post('pre-create') @UseMiddlewares(auth, customerServiceOnly) - @ResponseBody(UserSearchResult) + @ResponseBody(UserResponse) async preCreate(@Body(new ZodValidationPipe(preCraeteSchema)) data: PreCreateUserData) { const { email, username } = data; if (!email && !username) { diff --git a/next/api/src/response/user.ts b/next/api/src/response/user.ts index a08158b20..d329ffc3e 100644 --- a/next/api/src/response/user.ts +++ b/next/api/src/response/user.ts @@ -32,14 +32,6 @@ export class UserResponse { nickname: this.user.name ?? this.user.username, active: !this.user.inactive, avatarUrl: GravatarUrlManager.getUrl(this.user.email ?? this.user.username), - }; - } -} - -export class UserSearchResult extends UserResponse { - toJSON() { - return { - ...super.toJSON(), email: this.user.email, }; } diff --git a/next/api/src/ticket/export/ExportTicket.ts b/next/api/src/ticket/export/ExportTicket.ts index f582e5e4e..23aa62c57 100644 --- a/next/api/src/ticket/export/ExportTicket.ts +++ b/next/api/src/ticket/export/ExportTicket.ts @@ -3,7 +3,7 @@ import { debug as d } from 'debug'; import { sub, format as dateFnsFormat } from 'date-fns'; import { Category } from '@/model/Category'; import { User } from '@/model/User'; -import { UserSearchResult } from '@/response/user'; +import { UserResponse } from '@/response/user'; import { Group } from '@/model/Group'; import { GroupResponse } from '@/response/group'; import { Reply } from '@/model/Reply'; @@ -191,7 +191,7 @@ const getCategoryPath = async (category: Category) => { const getCustomerServices = async () => { const customerServices = await User.getCustomerServices(); return _(customerServices) - .map((user) => new UserSearchResult(user).toJSON()) + .map((user) => new UserResponse(user).toJSON()) .keyBy('id') .valueOf(); }; diff --git a/next/web/src/App/Admin/Settings/Collaborators/index.tsx b/next/web/src/App/Admin/Settings/Collaborators/index.tsx index eb8999e6b..e0439db40 100644 --- a/next/web/src/App/Admin/Settings/Collaborators/index.tsx +++ b/next/web/src/App/Admin/Settings/Collaborators/index.tsx @@ -91,6 +91,7 @@ export function Collaborators() {