Initial commit: PodcastYes — AI podcast platform
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
// Verify the Better Auth ↔ Prisma schema by performing a real signup.
|
||||
// Run: npx tsx scripts/test-auth.ts
|
||||
import "dotenv/config";
|
||||
import { auth } from "@/lib/auth/auth";
|
||||
import { prisma } from "@/lib/db";
|
||||
|
||||
async function main() {
|
||||
const email = `verify_${Date.now()}@podcastyes.test`;
|
||||
try {
|
||||
await auth.api.signUpEmail({
|
||||
body: { email, password: "Password123!", name: "Verify User" },
|
||||
});
|
||||
console.log("signUpEmail: completed");
|
||||
} catch (e) {
|
||||
// The nextCookies plugin may throw when run outside a Next request — the DB
|
||||
// write happens first, so we still verify via the row below.
|
||||
console.log("signUpEmail threw (often just the cookie step):", (e as Error).message);
|
||||
}
|
||||
|
||||
const user = await prisma.user.findUnique({
|
||||
where: { email },
|
||||
include: { accounts: true, sessions: true },
|
||||
});
|
||||
|
||||
if (user) {
|
||||
console.log(
|
||||
`✓ Better Auth schema works — user=${user.email} role=${user.role} ` +
|
||||
`accounts=${user.accounts.length} (provider=${user.accounts[0]?.providerId}) ` +
|
||||
`hasPassword=${!!user.accounts[0]?.password}`
|
||||
);
|
||||
// Clean up the test user.
|
||||
await prisma.user.delete({ where: { id: user.id } });
|
||||
console.log("✓ test user cleaned up");
|
||||
} else {
|
||||
console.log("✗ No user row created — schema mismatch likely");
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.catch((e) => {
|
||||
console.error("Failed:", e.message ?? e);
|
||||
process.exit(1);
|
||||
})
|
||||
.finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user