Refactoring and fixes
This commit is contained in:
1 parent
9239b27216
commit
be3bcf2bf0
35 files changed
+64
-107
No files matched your search
@@ -4,7 +4,6 @@ import prisma from "@calcom/prisma";
|
||||
|
||||
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
||||
import type { UserResponse } from "@lib/types";
|
||||
import { getCalcomUserId } from "@lib/utils/getCalcomUserId";
|
||||
import {
|
||||
schemaQueryIdParseInt,
|
||||
withValidQueryIdTransformParseInt,
|
||||
@@ -91,7 +90,7 @@ export async function userById(req: NextApiRequest, res: NextApiResponse<UserRes
|
||||
const safeQuery = schemaQueryIdParseInt.safeParse(query);
|
||||
const safeBody = schemaUserBodyParams.safeParse(body);
|
||||
if (!safeQuery.success) throw new Error("Invalid request query", safeQuery.error);
|
||||
const userId = getCalcomUserId(res);
|
||||
const userId = req.userId;
|
||||
if (safeQuery.data.id === userId) {
|
||||
switch (method) {
|
||||
case "GET":
|
||||
|
||||
@@ -4,7 +4,6 @@ import prisma from "@calcom/prisma";
|
||||
|
||||
import { withMiddleware } from "@lib/helpers/withMiddleware";
|
||||
import { UsersResponse } from "@lib/types";
|
||||
import { getCalcomUserId } from "@lib/utils/getCalcomUserId";
|
||||
import { schemaUserPublic } from "@lib/validations/user";
|
||||
|
||||
/**
|
||||
@@ -25,7 +24,7 @@ import { schemaUserPublic } from "@lib/validations/user";
|
||||
* description: No users were found
|
||||
*/
|
||||
async function allUsers(req: NextApiRequest, res: NextApiResponse<UsersResponse>) {
|
||||
const userId = getCalcomUserId(res);
|
||||
const userId = req.userId;
|
||||
const data = await prisma.user.findMany({
|
||||
where: {
|
||||
id: userId,
|
||||
|
||||
Reference in new issue
Block a user