Fix jwt-token

This commit is contained in:
2025-09-16 08:15:56 +02:00
parent bdb0fb079b
commit a56ce40821

View File

@@ -426,8 +426,25 @@ async function loginLocal(req, res, next) {
const user = await User.findOne({ where: whereClause });
console.log('🔧 DEBUG: Found user:', user ? { id: user.id, username: user.username, tenant_id: user.tenant_id } : 'null');
if (!user || !await bcrypt.compare(password, user.password_hash)) {
console.log(`❌ Authentication failed for "${username}" in tenant "${req.tenant?.id}"`);
if (!user) {
console.log(`❌ Authentication failed for "${username}" in tenant "${req.tenant?.id}" - User not found`);
return res.status(401).json({
success: false,
message: 'Invalid credentials'
});
}
console.log('🔧 DEBUG: Comparing password with hash:', {
passwordLength: password.length,
hashLength: user.password_hash?.length,
hashPrefix: user.password_hash?.substring(0, 10) + '...'
});
const passwordMatch = await bcrypt.compare(password, user.password_hash);
console.log('🔧 DEBUG: Password match result:', passwordMatch);
if (!passwordMatch) {
console.log(`❌ Authentication failed for "${username}" in tenant "${req.tenant?.id}" - Invalid password`);
return res.status(401).json({
success: false,
message: 'Invalid credentials'