Update index.js
Browse files
index.js
CHANGED
|
@@ -101,7 +101,11 @@ app.post('/api/login', async (req, res) => {
|
|
| 101 |
const isValidPassword = await bcrypt.compare(password, user.password);
|
| 102 |
if (isValidPassword) {
|
| 103 |
req.session.userId = user._id;
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
} else {
|
| 106 |
res.status(401).json({ error: 'Invalid credentials' });
|
| 107 |
}
|
|
|
|
| 101 |
const isValidPassword = await bcrypt.compare(password, user.password);
|
| 102 |
if (isValidPassword) {
|
| 103 |
req.session.userId = user._id;
|
| 104 |
+
// Fetch all connections for this user
|
| 105 |
+
const connections = await db.collection('connections')
|
| 106 |
+
.find({ userId: user._id })
|
| 107 |
+
.toArray();
|
| 108 |
+
res.json({ success: true, connections });
|
| 109 |
} else {
|
| 110 |
res.status(401).json({ error: 'Invalid credentials' });
|
| 111 |
}
|