Download debug-auth.js from sarransh/task-manager-system: direct link, hf CLI and curl.
- Browser
- Download file 1.78 kB
-
https://huggingface.co/spaces/sarransh/task-manager-system/resolve/main/debug-auth.js
- Command line
-
hf download hf://spaces/sarransh/task-manager-system/debug-auth.js
-
curl -L -o debug-auth.js https://huggingface.co/spaces/sarransh/task-manager-system/resolve/main/debug-auth.js
1.78 kB
| const { PrismaClient } = require('@prisma/client'); | |
| const prisma = new PrismaClient(); | |
| const bcrypt = require('bcryptjs'); | |
| async function debugAuth() { | |
| try { | |
| const email = 'admin@example.com'; | |
| const password = 'admin'; | |
| console.log(`Checking user: ${email}`); | |
| const user = await prisma.user.findUnique({ | |
| where: { email } | |
| }); | |
| if (!user) { | |
| console.log('User NOT found in DB.'); | |
| console.log('Attempting to create user...'); | |
| const hashedPassword = await bcrypt.hash(password, 10); | |
| await prisma.user.create({ | |
| data: { | |
| email, | |
| passwordHash: hashedPassword, | |
| name: 'System Admin', | |
| username: 'admin', | |
| role: 'ADMIN' | |
| } | |
| }); | |
| console.log('User created successfully.'); | |
| } else { | |
| console.log('User FOUND in DB.'); | |
| console.log('Stored Hash:', user.passwordHash); | |
| const isValid = await bcrypt.compare(password, user.passwordHash); | |
| console.log(`Password '${password}' is valid?`, isValid); | |
| if (!isValid) { | |
| console.log('Updating password to ensure it is correct...'); | |
| const newHash = await bcrypt.hash(password, 10); | |
| await prisma.user.update({ | |
| where: { email }, | |
| data: { passwordHash: newHash } | |
| }); | |
| console.log('Password updated.'); | |
| } | |
| } | |
| } catch (e) { | |
| console.error('Error:', e); | |
| } finally { | |
| await prisma.$disconnect(); | |
| } | |
| } | |
| debugAuth(); | |