mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 06:29:23 +02:00
remove org from get client route
This commit is contained in:
parent
48963f24df
commit
d207318494
4 changed files with 12 additions and 13 deletions
|
@ -13,17 +13,16 @@ import { OpenAPITags, registry } from "@server/openApi";
|
|||
|
||||
const getClientSchema = z
|
||||
.object({
|
||||
clientId: z.string().transform(stoi).pipe(z.number().int().positive()),
|
||||
orgId: z.string()
|
||||
clientId: z.string().transform(stoi).pipe(z.number().int().positive())
|
||||
})
|
||||
.strict();
|
||||
|
||||
async function query(clientId: number, orgId: string) {
|
||||
async function query(clientId: number) {
|
||||
// Get the client
|
||||
const [client] = await db
|
||||
.select()
|
||||
.from(clients)
|
||||
.where(and(eq(clients.clientId, clientId), eq(clients.orgId, orgId)))
|
||||
.where(and(eq(clients.clientId, clientId)))
|
||||
.limit(1);
|
||||
|
||||
if (!client) {
|
||||
|
@ -47,9 +46,9 @@ export type GetClientResponse = NonNullable<Awaited<ReturnType<typeof query>>>;
|
|||
|
||||
registry.registerPath({
|
||||
method: "get",
|
||||
path: "/org/{orgId}/client/{clientId}",
|
||||
path: "/client/{clientId}",
|
||||
description: "Get a client by its client ID.",
|
||||
tags: [OpenAPITags.Client, OpenAPITags.Org],
|
||||
tags: [OpenAPITags.Client],
|
||||
request: {
|
||||
params: getClientSchema
|
||||
},
|
||||
|
@ -75,9 +74,9 @@ export async function getClient(
|
|||
);
|
||||
}
|
||||
|
||||
const { clientId, orgId } = parsedParams.data;
|
||||
const { clientId } = parsedParams.data;
|
||||
|
||||
const client = await query(clientId, orgId);
|
||||
const client = await query(clientId);
|
||||
|
||||
if (!client) {
|
||||
return next(
|
||||
|
|
|
@ -134,9 +134,9 @@ authenticated.get(
|
|||
);
|
||||
|
||||
authenticated.get(
|
||||
"/org/:orgId/client/:clientId",
|
||||
"/client/:clientId",
|
||||
verifyClientsEnabled,
|
||||
verifyOrgAccess,
|
||||
verifyClientAccess,
|
||||
verifyUserHasAction(ActionsEnum.getClient),
|
||||
client.getClient
|
||||
);
|
||||
|
|
|
@ -526,9 +526,9 @@ authenticated.get(
|
|||
);
|
||||
|
||||
authenticated.get(
|
||||
"/org/:orgId/client/:clientId",
|
||||
"/client/:clientId",
|
||||
verifyClientsEnabled,
|
||||
verifyApiKeyOrgAccess,
|
||||
verifyApiKeyClientAccess,
|
||||
verifyApiKeyHasAction(ActionsEnum.getClient),
|
||||
client.getClient
|
||||
);
|
||||
|
|
|
@ -21,7 +21,7 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
|
|||
let client = null;
|
||||
try {
|
||||
const res = await internal.get<AxiosResponse<GetClientResponse>>(
|
||||
`/org/${params.orgId}/client/${params.clientId}`,
|
||||
`/client/${params.clientId}`,
|
||||
await authCookieHeader()
|
||||
);
|
||||
client = res.data.data;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue