-
Notifications
You must be signed in to change notification settings - Fork 264
Expand file tree
/
Copy pathroute.ts
More file actions
25 lines (21 loc) · 842 Bytes
/
route.ts
File metadata and controls
25 lines (21 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { revokeToken } from '@/features/oauth/server';
import { apiHandler } from '@/lib/apiHandler';
import { hasEntitlement } from '@sourcebot/shared';
import { NextRequest } from 'next/server';
// RFC 7009: OAuth 2.0 Token Revocation
// Always returns 200 regardless of whether the token existed.
// @see: https://datatracker.ietf.org/doc/html/rfc7009
export const POST = apiHandler(async (request: NextRequest) => {
if (!hasEntitlement('oauth')) {
return Response.json(
{ error: 'access_denied', error_description: 'OAuth is not available on this plan.' },
{ status: 403 }
);
}
const formData = await request.formData();
const token = formData.get('token');
if (token) {
await revokeToken(token.toString());
}
return new Response(null, { status: 200 });
});