Skip to content

Commit

Permalink
feat: add validation
Browse files Browse the repository at this point in the history
  • Loading branch information
bigint committed Apr 14, 2024
1 parent 15eba5d commit 7c07d07
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion apps/api/src/routes/internal/leafwatch/profile/details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import logger from '@hey/lib/logger';
import catchedError from 'src/lib/catchedError';
import { SWR_CACHE_AGE_1_SEC_30_DAYS } from 'src/lib/constants';
import createClickhouseClient from 'src/lib/createClickhouseClient';
import { noBody } from 'src/lib/responses';
import validateIsStaff from 'src/lib/middlewares/validateIsStaff';
import { noBody, notAllowed } from 'src/lib/responses';

export const get: Handler = async (req, res) => {
const { id } = req.query;
Expand All @@ -13,6 +14,10 @@ export const get: Handler = async (req, res) => {
return noBody(res);
}

if (!(await validateIsStaff(req))) {
return notAllowed(res);
}

try {
const client = createClickhouseClient();
const rows = await client.query({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
import { AdjustmentsVerticalIcon } from '@heroicons/react/24/solid';
import { HEY_API_URL } from '@hey/data/constants';
import humanize from '@hey/lib/humanize';
import getAuthApiHeaders from '@lib/getAuthApiHeaders';
import { useQuery } from '@tanstack/react-query';
import axios from 'axios';

Expand All @@ -32,7 +33,7 @@ const LeafwatchDetails: FC<LeafwatchDetailsProps> = ({ profileId }) => {
try {
const response = await axios.get(
`${HEY_API_URL}/internal/leafwatch/profile/details`,
{ params: { id: profileId } }
{ headers: getAuthApiHeaders(), params: { id: profileId } }
);
const { data } = response;

Expand Down

1 comment on commit 7c07d07

@vercel
Copy link

@vercel vercel bot commented on 7c07d07 Apr 14, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./apps/web

web-heyxyz.vercel.app
heyxyz.vercel.app
web-git-main-heyxyz.vercel.app
hey.xyz

Please sign in to comment.