mirror of
https://git.zhongyuan.online/ytke/tap.git
synced 2026-11-24 22:15:18 -08:00
支持自部署需求管理、交付流程与飞书集成
This commit is contained in:
1 parent
4556a5b483
commit
e22b66d9dd
148 files changed
+8300
-6393
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { appPath } from '@/lib/base-path';
|
||||
import { sessionCookie } from '@/lib/server/auth';
|
||||
import { applicationOrigin } from '@/lib/server/database';
|
||||
import { completeFeishuAuth, consumeFeishuState, FeishuAuthError, feishuStateCookie } from '@/lib/server/feishu-auth';
|
||||
|
||||
export const runtime = 'nodejs';
|
||||
export const dynamic = 'force-dynamic';
|
||||
export async function GET(request: Request) {
|
||||
const headers = new Headers({ 'Cache-Control': 'no-store', 'Referrer-Policy': 'no-referrer' });
|
||||
let binding = false;
|
||||
try {
|
||||
const state = consumeFeishuState(request);
|
||||
binding = Boolean(state.account_id);
|
||||
headers.append('Set-Cookie', feishuStateCookie(''));
|
||||
const result = await completeFeishuAuth(request, state);
|
||||
if (result.token) headers.append('Set-Cookie', sessionCookie(result.token, request));
|
||||
headers.set('Location', applicationOrigin() + appPath(result.returnTo + (result.bound ? '?bound=1' : '')));
|
||||
} catch (error) {
|
||||
const code = error instanceof FeishuAuthError ? error.code : 'failed';
|
||||
headers.set('Location', applicationOrigin() + appPath(`${binding ? '/account/feishu' : '/login'}?feishuError=${code}`));
|
||||
}
|
||||
return new Response(null, { status: 303, headers });
|
||||
}
|
||||
Reference in new issue
Block a user