forked from bai/curriculum-project-hub
fix: show Feishu OAuth completion page
This commit is contained in:
@@ -273,6 +273,34 @@ export async function registerAuthRoutes(app: FastifyInstance, config: AuthRoute
|
||||
return reply.status(204).send();
|
||||
});
|
||||
|
||||
app.get("/auth/feishu/complete", async (request, reply) => {
|
||||
const query = request.query as { org?: string };
|
||||
const organizationName = typeof query.org === "string" && query.org.trim() !== ""
|
||||
? query.org.trim()
|
||||
: "当前组织";
|
||||
return reply.type("text/html").send(`<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Educraft 登录成功</title>
|
||||
<style>
|
||||
body{font-family:system-ui,sans-serif;display:flex;min-height:100vh;align-items:center;justify-content:center;margin:0;background:#f6f7f9;color:#1a1a1a}
|
||||
.card{background:#fff;padding:2rem 2.5rem;border-radius:12px;box-shadow:0 8px 24px rgba(0,0,0,.08);max-width:25rem;text-align:center}
|
||||
.ok{font-size:3rem;margin:0 0 .5rem}.hint{color:#646a73;line-height:1.6}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<main class="card">
|
||||
<p class="ok">✅</p>
|
||||
<h1>登录并加入组织成功</h1>
|
||||
<p>你已加入 ${escapeHtml(organizationName)}。</p>
|
||||
<p class="hint">现在可以关闭本页面,返回飞书群再次 @机器人继续使用。</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>`);
|
||||
});
|
||||
|
||||
app.get("/api/me", async (request, reply) => {
|
||||
try {
|
||||
const auth = await requireSession(request, reply, guardDeps);
|
||||
@@ -401,10 +429,13 @@ async function resolvePostLoginRedirect(
|
||||
revokedAt: null,
|
||||
organization: { status: "ACTIVE" },
|
||||
},
|
||||
select: { organization: { select: { slug: true } } },
|
||||
select: { organization: { select: { slug: true, name: true } } },
|
||||
});
|
||||
if (intended === null) return "/admin?error=not_an_active_org_member";
|
||||
const orgRoot = `/admin/org/${intended.organization.slug}`;
|
||||
if (returnTo === "/admin") {
|
||||
return `/auth/feishu/complete?org=${encodeURIComponent(intended.organization.name)}`;
|
||||
}
|
||||
return returnTo === orgRoot || returnTo.startsWith(`${orgRoot}/`) ? returnTo : orgRoot;
|
||||
}
|
||||
if (returnTo !== "/admin" && returnTo.startsWith("/admin")) {
|
||||
|
||||
Reference in New Issue
Block a user