14 lines
638 B
TypeScript
14 lines
638 B
TypeScript
import { assertSameOrigin, authFailure, jsonResponse, readJsonObject, requireApiUser, sessionCookie } from '@/lib/server/auth';
|
|||
|
|
import { unbindFeishu } from '@/lib/server/feishu-auth';
|
||
|
|
|
||
|
|
export const runtime = 'nodejs';
|
||
|
|
export const dynamic = 'force-dynamic';
|
||
|
|
export async function DELETE(request: Request) {
|
||
|
|
try {
|
||
|
|
assertSameOrigin(request);
|
||
|
|
const user = await requireApiUser();
|
||
|
|
const body = await readJsonObject(request);
|
||
|
|
const result = await unbindFeishu(user, body.password, request);
|
||
|
|
return jsonResponse({ ok: true }, 200, sessionCookie(result.token, request));
|
||
|
|
} catch (error) { return authFailure(error); }
|
||
|
|
}
|