v0.10.9 update ui settings
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "jama-backend",
|
||||
"version": "0.10.8",
|
||||
"version": "0.10.9",
|
||||
"description": "TeamChat backend server",
|
||||
"main": "src/index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -191,6 +191,8 @@ router.patch('/:id/suspend', authMiddleware, adminMiddleware, async (req, res)
|
||||
if (!t) return res.status(404).json({ error: 'User not found' });
|
||||
if (t.is_default_admin) return res.status(403).json({ error: 'Cannot suspend default admin' });
|
||||
await exec(req.schema, "UPDATE users SET status='suspended', updated_at=NOW() WHERE id=$1", [t.id]);
|
||||
// Clear active sessions so suspended user is immediately kicked
|
||||
await exec(req.schema, 'DELETE FROM active_sessions WHERE user_id=$1', [t.id]);
|
||||
res.json({ success: true });
|
||||
} catch (e) { res.status(500).json({ error: e.message }); }
|
||||
});
|
||||
@@ -205,7 +207,25 @@ router.delete('/:id', authMiddleware, adminMiddleware, async (req, res)
|
||||
const t = await queryOne(req.schema, 'SELECT * FROM users WHERE id=$1', [req.params.id]);
|
||||
if (!t) return res.status(404).json({ error: 'User not found' });
|
||||
if (t.is_default_admin) return res.status(403).json({ error: 'Cannot delete default admin' });
|
||||
|
||||
// Mark deleted
|
||||
await exec(req.schema, "UPDATE users SET status='deleted', updated_at=NOW() WHERE id=$1", [t.id]);
|
||||
|
||||
// Remove from all chat group memberships
|
||||
await exec(req.schema, 'DELETE FROM group_members WHERE user_id=$1', [t.id]);
|
||||
|
||||
// Remove from all user groups (managed groups)
|
||||
await exec(req.schema, 'DELETE FROM user_group_members WHERE user_id=$1', [t.id]);
|
||||
|
||||
// Clear all active sessions so they cannot log in
|
||||
await exec(req.schema, 'DELETE FROM active_sessions WHERE user_id=$1', [t.id]);
|
||||
|
||||
// Remove push subscriptions
|
||||
await exec(req.schema, 'DELETE FROM push_subscriptions WHERE user_id=$1', [t.id]);
|
||||
|
||||
// Remove event availability responses
|
||||
await exec(req.schema, 'DELETE FROM event_availability WHERE user_id=$1', [t.id]);
|
||||
|
||||
res.json({ success: true });
|
||||
} catch (e) { res.status(500).json({ error: e.message }); }
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user