Work with DB fixed including default Admin creation

This commit is contained in:
aodulov
2025-12-12 11:51:57 +02:00
parent bc1b747ef4
commit 3ede054766
14 changed files with 106 additions and 106 deletions

37
server/repro_login.ts Normal file
View File

@@ -0,0 +1,37 @@
import { AuthService } from './src/services/auth.service';
import prisma from './src/lib/prisma';
import bcrypt from 'bcryptjs';
// const prisma = new PrismaClient(); // Removed local instance
async function run() {
try {
console.log("Setting up test user...");
const email = 'repro_user@gymflow.ai';
const password = 'password123';
const hashed = await bcrypt.hash(password, 10);
await prisma.user.upsert({
where: { email },
update: { password: hashed, isBlocked: false },
create: {
email,
password: hashed,
role: 'USER',
profile: { create: { weight: 70 } }
}
});
console.log("Attempting login...");
const result = await AuthService.login(email, password);
console.log("Login success:", result ? "OK" : "No result");
} catch (error) {
console.error("Login failed with error:");
console.error(error);
} finally {
await prisma.$disconnect();
}
}
run();