🐛 fix: limit check-user response surface (#10609)

This commit is contained in:
YuTengjing 2025-12-05 00:42:41 +08:00 committed by GitHub
parent c09f2474db
commit 2f6d3f0172
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,10 +6,8 @@ import { users } from '@/database/schemas/user';
import { serverDB } from '@/database/server';
export interface CheckUserResponseData {
emailVerified?: boolean;
exists: boolean;
hasPassword?: boolean;
providers?: string[];
}
/**
@ -47,18 +45,14 @@ export async function POST(req: NextRequest) {
})
.from(account)
.where(and(eq(account.userId, user.id)));
const providers = Array.from(new Set(accounts.map((a) => a.providerId).filter(Boolean)));
const hasPassword = accounts.some(
(a) =>
a.providerId === 'credential' && typeof a.password === 'string' && a.password.length > 0,
);
return NextResponse.json({
emailVerified: user.emailVerified,
exists: true,
hasPassword,
providers,
} satisfies CheckUserResponseData);
} catch (error) {
console.error('Error checking user existence:', error);