支持自部署需求管理、交付流程与飞书集成

This commit is contained in:
xyt committed 2026-11-25 12:40:33 +08:00
1 parent 2149aeb6ed
commit 51a2e548f2
152 files changed
+8652 -6394

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
import { appPath } from '@/lib/base-path';
import { assertSameOrigin, AuthError } from '@/lib/server/auth';
import { applicationOrigin } from '@/lib/server/database';
import { beginFeishuAuth, FeishuAuthError } from '@/lib/server/feishu-auth';
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
export async function POST(request: Request) {
let intent = 'login';
try {
assertSameOrigin(request);
const raw = await request.text();
if (raw.length > 8192) throw new FeishuAuthError('failed');
const form = new URLSearchParams(raw);
intent = form.get('intent') || 'login';
const result = beginFeishuAuth(request, intent, form.get('next'));
return new Response(null, { status: 303, headers: { Location: result.url, 'Set-Cookie': result.cookie, 'Cache-Control': 'no-store' } });
} catch (error) {
const code = error instanceof FeishuAuthError ? error.code : error instanceof AuthError && error.status === 429 ? 'rate_limited' : error instanceof AuthError && error.status === 403 ? 'source' : 'failed';
return new Response(null, { status: 303, headers: { Location: applicationOrigin() + appPath(`${intent === 'bind' ? '/account/feishu' : '/login'}?feishuError=${code}`), 'Cache-Control': 'no-store' } });
}
}