mirror of
https://git.zhongyuan.online/ytke/tap.git
synced 2026-11-24 22:15:18 -08:00
37 lines
2.2 KiB
TypeScript
37 lines
2.2 KiB
TypeScript
import { redirect } from 'next/navigation';
|
|||
|
|
import { LoginForm } from '@/components/account/login-form';
|
||
|
|
import { getCurrentUser } from '@/lib/server/auth';
|
||
|
|
import { feishuLoginConfigured } from '@/lib/server/feishu-config';
|
||
|
|
import { safeReturnTo } from '@/lib/auth-return';
|
||
|
|
import { feishuErrorMessage } from '@/lib/feishu';
|
||
|
|
import { appPath } from '@/lib/base-path';
|
||
|
|
|
||
|
|
export const runtime = 'nodejs';
|
||
|
|
export const dynamic = 'force-dynamic';
|
||
|
|
|
||
|
|
export default async function LoginPage({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {
|
||
|
|
const params = await searchParams;
|
||
|
|
const next = safeReturnTo(params.next);
|
||
|
|
const user = await getCurrentUser();
|
||
|
|
if (user) redirect(user.mustChangePassword ? '/account/password' : next);
|
||
|
|
const error = feishuErrorMessage(params.feishuError);
|
||
|
|
const feishuEnabled = feishuLoginConfigured();
|
||
|
|
return <main className="account-page">
|
||
|
|
<div className="account-brand brand"><div className="brand-mark" aria-hidden="true"><i /><i /><i /><i /></div><div><strong>需有序</strong><span>需求协作平台</span></div></div>
|
||
|
|
<section className="account-card" aria-labelledby="login-title">
|
||
|
|
<h1 id="login-title">登录工作台</h1>
|
||
|
|
<p className="account-intro">登记需求,跟进进度,让业务协作更有序。</p>
|
||
|
|
{error && <div className="error-banner" role="alert">{error}</div>}
|
||
|
|
<LoginForm returnTo={next} />
|
||
|
|
{feishuEnabled && <div className="feishu-login">
|
||
|
|
<span className="feishu-divider">或使用飞书</span>
|
||
|
|
<form action={appPath('/api/auth/feishu/start')} method="post">
|
||
|
|
<input type="hidden" name="intent" value="login" /><input type="hidden" name="next" value={next} />
|
||
|
|
<button type="submit" className="btn feishu-login-button">飞书登录</button>
|
||
|
|
</form>
|
||
|
|
<p className="account-help">首次飞书登录将自动注册普通成员账号。已有系统账号请先用密码登录并绑定飞书,以保留原有需求。</p>
|
||
|
|
</div>}
|
||
|
|
</section>
|
||
|
|
<p className="account-page-note">{feishuEnabled ? '支持管理员开通的账号,或通过飞书首次登录自动注册。' : '使用本系统账号登录,账号由管理员统一开通。'}</p>
|
||
|
|
</main>;
|
||
|
|
}
|