mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-15 09:26:40 +00:00
Move to string ordId
This commit is contained in:
@@ -8,13 +8,13 @@ import { AuthenticatedRequest } from '@server/types/Auth';
|
||||
|
||||
export function verifyOrgAccess(req: Request, res: Response, next: NextFunction) {
|
||||
const userId = req.user!.userId; // Assuming you have user information in the request
|
||||
const orgId = parseInt(req.params.orgId);
|
||||
const orgId = req.params.orgId;
|
||||
|
||||
if (!userId) {
|
||||
return next(createHttpError(HttpCode.UNAUTHORIZED, 'User not authenticated'));
|
||||
}
|
||||
|
||||
if (isNaN(orgId)) {
|
||||
if (!orgId) {
|
||||
return next(createHttpError(HttpCode.BAD_REQUEST, 'Invalid organization ID'));
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ActionsEnum, checkUserActionPermission } from '@server/auth/actions';
|
||||
import logger from '@server/logger';
|
||||
|
||||
const deleteOrgSchema = z.object({
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
export async function deleteOrg(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ActionsEnum, checkUserActionPermission } from '@server/auth/actions';
|
||||
import logger from '@server/logger';
|
||||
|
||||
const getOrgSchema = z.object({
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
export async function getOrg(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
||||
@@ -10,7 +10,7 @@ import { ActionsEnum, checkUserActionPermission } from '@server/auth/actions';
|
||||
import logger from '@server/logger';
|
||||
|
||||
const updateOrgParamsSchema = z.object({
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
const updateOrgBodySchema = z.object({
|
||||
|
||||
@@ -11,7 +11,7 @@ import { eq, and } from 'drizzle-orm';
|
||||
|
||||
const createResourceParamsSchema = z.object({
|
||||
siteId: z.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
// Define Zod schema for request body validation
|
||||
|
||||
@@ -13,7 +13,7 @@ import { eq, and } from 'drizzle-orm';
|
||||
const API_BASE_URL = "http://localhost:3000";
|
||||
|
||||
const createSiteParamsSchema = z.object({
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
// Define Zod schema for request body validation
|
||||
|
||||
@@ -12,7 +12,7 @@ import { eq } from 'drizzle-orm';
|
||||
const addUserActionSchema = z.object({
|
||||
userId: z.string(),
|
||||
actionId: z.string(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive()),
|
||||
orgId: z.string(),
|
||||
});
|
||||
|
||||
export async function addUserAction(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
||||
@@ -11,7 +11,7 @@ import logger from '@server/logger';
|
||||
|
||||
const addUserParamsSchema = z.object({
|
||||
userId: z.string().uuid(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
const addUserSchema = z.object({
|
||||
|
||||
@@ -15,7 +15,7 @@ const removeUserActionParamsSchema = z.object({
|
||||
|
||||
const removeUserActionSchema = z.object({
|
||||
actionId: z.string(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
export async function removeUserAction(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
||||
@@ -11,7 +11,7 @@ import logger from '@server/logger';
|
||||
|
||||
const removeUserSchema = z.object({
|
||||
userId: z.string().uuid(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
export async function removeUserOrg(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
||||
@@ -12,7 +12,7 @@ import logger from '@server/logger';
|
||||
const addUserRoleSchema = z.object({
|
||||
userId: z.string(),
|
||||
roleId: z.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
orgId: z.string()
|
||||
});
|
||||
|
||||
export async function addUserRole(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
||||
Reference in New Issue
Block a user