mirror of
https://github.com/fosrl/pangolin.git
synced 2026-02-13 16:36:41 +00:00
Trying to add site provider
This commit is contained in:
@@ -54,13 +54,14 @@ export async function createSuperuserRole(orgId: number) {
|
||||
|
||||
const roleId = insertedRole.roleId;
|
||||
|
||||
// Add all current actions to the new Default role
|
||||
const actionIds = Object.values(ActionsEnum);
|
||||
const actionIds = await db.select().from(actions).execute();
|
||||
|
||||
if (actionIds.length === 0) {
|
||||
logger.info('No actions to assign to the Superuser role');
|
||||
return;
|
||||
}
|
||||
|
||||
await db.insert(roleActions)
|
||||
.values(actionIds.map(actionId => ({
|
||||
roleId,
|
||||
actionId: actionId,
|
||||
orgId
|
||||
})))
|
||||
.values(actionIds.map(action => ({ roleId, actionId: action.actionId, orgId })))
|
||||
.execute();
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import { eq, and } from 'drizzle-orm';
|
||||
|
||||
const createResourceParamsSchema = z.object({
|
||||
siteId: z.number().int().positive(),
|
||||
orgId: z.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
});
|
||||
|
||||
// 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.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
});
|
||||
|
||||
// Define Zod schema for request body validation
|
||||
|
||||
@@ -14,6 +14,14 @@ const getSiteSchema = z.object({
|
||||
siteId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
});
|
||||
|
||||
export type GetSiteResponse = {
|
||||
siteId: number;
|
||||
name: string;
|
||||
subdomain: string;
|
||||
pubKey: string;
|
||||
subnet: string;
|
||||
}
|
||||
|
||||
export async function getSite(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
try {
|
||||
// Validate request parameters
|
||||
|
||||
@@ -11,7 +11,7 @@ import logger from '@server/logger';
|
||||
|
||||
const addUserParamsSchema = z.object({
|
||||
userId: z.string().uuid(),
|
||||
orgId: z.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
});
|
||||
|
||||
const addUserSchema = z.object({
|
||||
|
||||
@@ -15,7 +15,7 @@ const removeUserActionParamsSchema = z.object({
|
||||
|
||||
const removeUserActionSchema = z.object({
|
||||
actionId: z.string(),
|
||||
orgId: z.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
});
|
||||
|
||||
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.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
});
|
||||
|
||||
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.number().int().positive(),
|
||||
orgId: z.string().transform(Number).pipe(z.number().int().positive())
|
||||
});
|
||||
|
||||
export async function addUserRole(req: Request, res: Response, next: NextFunction): Promise<any> {
|
||||
|
||||
Reference in New Issue
Block a user