Work with DB fixed including default Admin creation
This commit is contained in:
37
server/repro_login.ts
Normal file
37
server/repro_login.ts
Normal 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();
|
||||
Reference in New Issue
Block a user