22 lines
677 B
TypeScript
22 lines
677 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { userHasBoundThreadsAccount } from "@/lib/auth/accounts";
|
|
import { getSessionUser } from "@/lib/auth/session";
|
|
import { apiRouteErrorResponse } from "@/lib/auth/api";
|
|
|
|
export async function GET() {
|
|
try {
|
|
const user = await getSessionUser();
|
|
if (!user) {
|
|
return NextResponse.json({ error: "未登入" }, { status: 401 });
|
|
}
|
|
|
|
const needsThreadsBind = !(await userHasBoundThreadsAccount(user.id));
|
|
|
|
return NextResponse.json({
|
|
user: { id: user.id, email: user.email, name: user.name },
|
|
needsThreadsBind,
|
|
});
|
|
} catch (error) {
|
|
return apiRouteErrorResponse(error, "auth/me");
|
|
}
|
|
} |