feat(licenses): add POST /licenses/revoke endpoint
Sets license status to 'revoked' and clears all device activations. Returns the updated license doc. Idempotent — already-revoked licenses return immediately.
This commit is contained in:
parent
972a1a21d7
commit
5622499575
@ -177,6 +177,23 @@ export async function licenseRoutes(app: FastifyInstance) {
|
||||
return updated;
|
||||
});
|
||||
|
||||
// Revoke license
|
||||
app.post('/licenses/revoke', async req => {
|
||||
const { key } = req.body as { key: string };
|
||||
if (!key) throw new BadRequestError('key is required');
|
||||
const productId = getRequestProductId(req);
|
||||
const license = await repo.getByKey(key, productId);
|
||||
if (!license) throw new NotFoundError('License not found');
|
||||
if (license.status === 'revoked') return license;
|
||||
|
||||
const updated = await repo.update(license.id, license.userId, {
|
||||
status: 'revoked',
|
||||
deviceIds: [],
|
||||
});
|
||||
if (!updated) throw new NotFoundError('License update failed');
|
||||
return updated;
|
||||
});
|
||||
|
||||
// Status
|
||||
app.get('/licenses/status/:key', async req => {
|
||||
const { key } = req.params as { key: string };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user