feat: complete user management workflow

This commit is contained in:
2026-07-02 01:18:52 -07:00
parent e3e7b0d8e0
commit 99bcfb1038
12 changed files with 663 additions and 46 deletions

View File

@@ -36,8 +36,13 @@ export async function POST(request: Request): Promise<Response> {
password,
organizationId: organizationId || undefined,
});
await setSessionCookie(created.session.id);
return jsonSuccess("账号已创建", { account: created.account });
if (created.session) {
await setSessionCookie(created.session.id);
}
return jsonSuccess(organizationId ? "申请已提交,待机构管理员审批" : "账号已创建", {
account: created.account,
pendingApproval: !created.session,
});
} catch (error) {
const reason = error instanceof Error ? error.message : "账号创建失败";
const status = reason === "账号已存在" ? 409 : 500;