Files

24 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

import Link from 'next/link';
import { hasAccountPassword, requireUser } from '@/lib/server/auth';
import { getFeishuBinding } from '@/lib/server/feishu-auth';
import { feishuLoginConfigured } from '@/lib/server/feishu-config';
import { FeishuAccount } from '@/components/account/feishu-account';
import { feishuErrorMessage } from '@/lib/feishu';
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
export default async function FeishuAccountPage({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {
const user = await requireUser('/account/feishu');
const params = await searchParams;
const error = feishuErrorMessage(params.feishuError);
return <main className="account-page">
<section className="account-card" aria-labelledby="feishu-title">
<h1 id="feishu-title">飞书绑定</h1>
<p className="account-intro">当前账号:<strong>{user.displayName}({user.username})</strong><br />绑定后可通过飞书登录,继续使用当前账号的需求和权限。</p>
{error && <div className="error-banner" role="alert">{error}</div>}
{params.bound === '1' && <div className="account-success" role="status">飞书账号已绑定,下次可使用飞书登录。</div>}
<FeishuAccount binding={getFeishuBinding(user.userId)} configured={feishuLoginConfigured()} passwordSet={hasAccountPassword(user.userId)} />
<div className="account-form-footer"><Link className="text-button" href="/">返回工作台</Link>{user.role === 'admin' && <Link className="text-button" href="/admin/feishu">飞书集成管理</Link>}</div>
</section>
</main>;
}