fix(striker-ui-api): identify current user when getting users

main
Tsu-ba-me 2 years ago
parent c1fcaf5161
commit 75068c1957
  1. 16
      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<string, { userName: string; userUUID: string }>
>((previous, [userName, userUUID]) => {
previous[userUUID] = {
>((previous, [userName, userUuid]) => {
const key = userUuid === sessionUserUuid ? 'current' : userUuid;
previous[key] = {
userName,
userUUID,
userUUID: userUuid,
};
return previous;

Loading…
Cancel
Save