gre89 commited on
Commit
05bbd4f
·
verified ·
1 Parent(s): 7d3fb99

Update index.js

Browse files
Files changed (1) hide show
  1. index.js +5 -1
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
- res.json({ success: true });
 
 
 
 
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
  }