From 75068c19578e151312551bb230b345652746e92e Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Tue, 6 Jun 2023 20:36:09 -0400 Subject: [PATCH] fix(striker-ui-api): identify current user when getting users --- .../src/lib/request_handlers/user/getUser.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/striker-ui-api/src/lib/request_handlers/user/getUser.ts b/striker-ui-api/src/lib/request_handlers/user/getUser.ts index 1551ecc8..f67ee5db 100644 --- a/striker-ui-api/src/lib/request_handlers/user/getUser.ts +++ b/striker-ui-api/src/lib/request_handlers/user/getUser.ts @@ -2,18 +2,22 @@ import buildGetRequestHandler from '../buildGetRequestHandler'; import { buildQueryResultReducer } from '../../buildQueryResultModifier'; export const getUser = buildGetRequestHandler((request, buildQueryOptions) => { + const { user: { uuid: sessionUserUuid } = {} } = request; + const query = ` SELECT - use.user_name, - use.user_uuid - FROM users AS use;`; + a.user_name, + a.user_uuid + FROM users AS a;`; const afterQueryReturn: QueryResultModifierFunction | undefined = buildQueryResultReducer< Record - >((previous, [userName, userUUID]) => { - previous[userUUID] = { + >((previous, [userName, userUuid]) => { + const key = userUuid === sessionUserUuid ? 'current' : userUuid; + + previous[key] = { userName, - userUUID, + userUUID: userUuid, }; return previous;