Fix jwt-token
This commit is contained in:
@@ -426,8 +426,25 @@ async function loginLocal(req, res, next) {
|
|||||||
const user = await User.findOne({ where: whereClause });
|
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');
|
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)) {
|
if (!user) {
|
||||||
console.log(`❌ Authentication failed for "${username}" in tenant "${req.tenant?.id}"`);
|
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({
|
return res.status(401).json({
|
||||||
success: false,
|
success: false,
|
||||||
message: 'Invalid credentials'
|
message: 'Invalid credentials'
|
||||||
|
|||||||
Reference in New Issue
Block a user