mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 17:47:27 +00:00
🐛 fix: limit check-user response surface (#10609)
This commit is contained in:
parent
c09f2474db
commit
2f6d3f0172
1 changed files with 0 additions and 6 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in a new issue