mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
Merge pull request #5232 from logto-io/gao-get-delete-invitation
feat(core): get and delete org invitation by id
This commit is contained in:
commit
ca24e20f6a
3 changed files with 50 additions and 22 deletions
|
@ -17,6 +17,48 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/api/organization-invitations/{id}": {
|
||||||
|
"get": {
|
||||||
|
"summary": "Get organization invitation",
|
||||||
|
"description": "Get an organization invitation by ID.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"description": "The organization invitation ID.",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "The organization invitation, also contains the organization roles to be assigned to the user when they accept the invitation, and the corresponding magic link data."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"delete": {
|
||||||
|
"summary": "Delete organization invitation",
|
||||||
|
"description": "Delete an organization invitation by ID.",
|
||||||
|
"parameters": [
|
||||||
|
{
|
||||||
|
"name": "id",
|
||||||
|
"in": "path",
|
||||||
|
"description": "The organization invitation ID.",
|
||||||
|
"required": true,
|
||||||
|
"schema": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"responses": {
|
||||||
|
"204": {
|
||||||
|
"description": "The organization invitation was deleted successfully."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import { OrganizationInvitations, organizationInvitationEntityGuard } from '@logto/schemas';
|
import { OrganizationInvitations } from '@logto/schemas';
|
||||||
import Router, { type IRouterParamContext } from 'koa-router';
|
|
||||||
|
|
||||||
import koaGuard from '#src/middleware/koa-guard.js';
|
import SchemaRouter from '#src/utils/SchemaRouter.js';
|
||||||
import koaPagination from '#src/middleware/koa-pagination.js';
|
|
||||||
import { tableToPathname } from '#src/utils/SchemaRouter.js';
|
|
||||||
|
|
||||||
import { type AuthedRouter, type RouterInitArgs } from '../types.js';
|
import { type AuthedRouter, type RouterInitArgs } from '../types.js';
|
||||||
|
|
||||||
|
@ -17,24 +14,12 @@ export default function organizationInvitationRoutes<T extends AuthedRouter>(
|
||||||
},
|
},
|
||||||
]: RouterInitArgs<T>
|
]: RouterInitArgs<T>
|
||||||
) {
|
) {
|
||||||
const router = new Router<unknown, IRouterParamContext>({
|
const router = new SchemaRouter(OrganizationInvitations, invitations, {
|
||||||
prefix: '/' + tableToPathname(OrganizationInvitations.table),
|
disabled: {
|
||||||
|
post: true,
|
||||||
|
patchById: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
router.get(
|
|
||||||
'/',
|
|
||||||
koaPagination(),
|
|
||||||
koaGuard({ response: organizationInvitationEntityGuard.array(), status: [200] }),
|
|
||||||
async (ctx, next) => {
|
|
||||||
const { limit, offset } = ctx.pagination;
|
|
||||||
const [count, entities] = await invitations.findAll(limit, offset);
|
|
||||||
|
|
||||||
ctx.pagination.totalCount = count;
|
|
||||||
ctx.body = entities;
|
|
||||||
ctx.status = 200;
|
|
||||||
return next();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
originalRouter.use(router.routes());
|
originalRouter.use(router.routes());
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ const identifiableEntityNames = [
|
||||||
'organization',
|
'organization',
|
||||||
'organization-role',
|
'organization-role',
|
||||||
'organization-scope',
|
'organization-scope',
|
||||||
|
'organization-invitation',
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue