mirror of
https://github.com/fosrl/pangolin.git
synced 2025-08-30 22:49:27 +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
|
const getClientSchema = z
|
||||||
.object({
|
.object({
|
||||||
clientId: z.string().transform(stoi).pipe(z.number().int().positive()),
|
clientId: z.string().transform(stoi).pipe(z.number().int().positive())
|
||||||
orgId: z.string()
|
|
||||||
})
|
})
|
||||||
.strict();
|
.strict();
|
||||||
|
|
||||||
async function query(clientId: number, orgId: string) {
|
async function query(clientId: number) {
|
||||||
// Get the client
|
// Get the client
|
||||||
const [client] = await db
|
const [client] = await db
|
||||||
.select()
|
.select()
|
||||||
.from(clients)
|
.from(clients)
|
||||||
.where(and(eq(clients.clientId, clientId), eq(clients.orgId, orgId)))
|
.where(and(eq(clients.clientId, clientId)))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
|
@ -47,9 +46,9 @@ export type GetClientResponse = NonNullable<Awaited<ReturnType<typeof query>>>;
|
||||||
|
|
||||||
registry.registerPath({
|
registry.registerPath({
|
||||||
method: "get",
|
method: "get",
|
||||||
path: "/org/{orgId}/client/{clientId}",
|
path: "/client/{clientId}",
|
||||||
description: "Get a client by its client ID.",
|
description: "Get a client by its client ID.",
|
||||||
tags: [OpenAPITags.Client, OpenAPITags.Org],
|
tags: [OpenAPITags.Client],
|
||||||
request: {
|
request: {
|
||||||
params: getClientSchema
|
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) {
|
if (!client) {
|
||||||
return next(
|
return next(
|
||||||
|
|
|
@ -134,9 +134,9 @@ authenticated.get(
|
||||||
);
|
);
|
||||||
|
|
||||||
authenticated.get(
|
authenticated.get(
|
||||||
"/org/:orgId/client/:clientId",
|
"/client/:clientId",
|
||||||
verifyClientsEnabled,
|
verifyClientsEnabled,
|
||||||
verifyOrgAccess,
|
verifyClientAccess,
|
||||||
verifyUserHasAction(ActionsEnum.getClient),
|
verifyUserHasAction(ActionsEnum.getClient),
|
||||||
client.getClient
|
client.getClient
|
||||||
);
|
);
|
||||||
|
|
|
@ -526,9 +526,9 @@ authenticated.get(
|
||||||
);
|
);
|
||||||
|
|
||||||
authenticated.get(
|
authenticated.get(
|
||||||
"/org/:orgId/client/:clientId",
|
"/client/:clientId",
|
||||||
verifyClientsEnabled,
|
verifyClientsEnabled,
|
||||||
verifyApiKeyOrgAccess,
|
verifyApiKeyClientAccess,
|
||||||
verifyApiKeyHasAction(ActionsEnum.getClient),
|
verifyApiKeyHasAction(ActionsEnum.getClient),
|
||||||
client.getClient
|
client.getClient
|
||||||
);
|
);
|
||||||
|
|
|
@ -21,7 +21,7 @@ export default async function SettingsLayout(props: SettingsLayoutProps) {
|
||||||
let client = null;
|
let client = null;
|
||||||
try {
|
try {
|
||||||
const res = await internal.get<AxiosResponse<GetClientResponse>>(
|
const res = await internal.get<AxiosResponse<GetClientResponse>>(
|
||||||
`/org/${params.orgId}/client/${params.clientId}`,
|
`/client/${params.clientId}`,
|
||||||
await authCookieHeader()
|
await authCookieHeader()
|
||||||
);
|
);
|
||||||
client = res.data.data;
|
client = res.data.data;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue