in packages/better-auth/src/plugins/organization/organization.ts [488:562]
hasPermission: createAuthEndpoint(
"/organization/has-permission",
{
method: "POST",
requireHeaders: true,
body: z
.object({
organizationId: z.string().optional(),
})
.and(
z.union([
z.object({
permission: z.record(z.string(), z.array(z.string())),
permissions: z.undefined(),
}),
z.object({
permission: z.undefined(),
permissions: z.record(z.string(), z.array(z.string())),
}),
]),
),
use: [orgSessionMiddleware],
metadata: {
$Infer: {
body: {} as PermissionExclusive & {
organizationId?: string;
},
},
openapi: {
description: "Check if the user has permission",
requestBody: {
content: {
"application/json": {
schema: {
type: "object",
properties: {
permission: {
type: "object",
description: "The permission to check",
deprecated: true,
},
permissions: {
type: "object",
description: "The permission to check",
},
},
required: ["permissions"],
},
},
},
},
responses: {
"200": {
description: "Success",
content: {
"application/json": {
schema: {
type: "object",
properties: {
error: {
type: "string",
},
success: {
type: "boolean",
},
},
required: ["success"],
},
},
},
},
},
},
},
},