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 f67ee5db..0d2d0d07 100644 --- a/striker-ui-api/src/lib/request_handlers/user/getUser.ts +++ b/striker-ui-api/src/lib/request_handlers/user/getUser.ts @@ -2,13 +2,22 @@ import buildGetRequestHandler from '../buildGetRequestHandler'; import { buildQueryResultReducer } from '../../buildQueryResultModifier'; export const getUser = buildGetRequestHandler((request, buildQueryOptions) => { - const { user: { uuid: sessionUserUuid } = {} } = request; + const { user: { name: sessionUserName, uuid: sessionUserUuid } = {} } = + request; + + let condLimitRegular = ''; + + if (sessionUserName !== 'admin') { + condLimitRegular = `WHERE user_uuid = '${sessionUserUuid}'`; + } const query = ` SELECT a.user_name, a.user_uuid - FROM users AS a;`; + FROM users AS a + ${condLimitRegular};`; + const afterQueryReturn: QueryResultModifierFunction | undefined = buildQueryResultReducer< Record