version 0.0.24
This commit is contained in:
@@ -55,7 +55,7 @@ app.get('/manifest.json', (req, res) => {
|
||||
const s = {};
|
||||
for (const r of rows) s[r.key] = r.value;
|
||||
|
||||
const appName = s.app_name || process.env.APP_NAME || 'TeamChat';
|
||||
const appName = s.app_name || process.env.APP_NAME || 'jama';
|
||||
const pwa192 = s.pwa_icon_192 || '';
|
||||
const pwa512 = s.pwa_icon_512 || '';
|
||||
|
||||
@@ -104,7 +104,12 @@ io.use((socket, next) => {
|
||||
const db = getDb();
|
||||
const user = db.prepare('SELECT id, name, display_name, avatar, role, status FROM users WHERE id = ? AND status = ?').get(decoded.id, 'active');
|
||||
if (!user) return next(new Error('User not found'));
|
||||
// Per-device enforcement: token must match an active session row
|
||||
const session = db.prepare('SELECT * FROM active_sessions WHERE user_id = ? AND token = ?').get(decoded.id, token);
|
||||
if (!session) return next(new Error('Session displaced'));
|
||||
socket.user = user;
|
||||
socket.token = token;
|
||||
socket.device = session.device;
|
||||
next();
|
||||
} catch (e) {
|
||||
next(new Error('Invalid token'));
|
||||
@@ -305,5 +310,5 @@ io.on('connection', (socket) => {
|
||||
});
|
||||
|
||||
server.listen(PORT, () => {
|
||||
console.log(`TeamChat server running on port ${PORT}`);
|
||||
console.log(`jama server running on port ${PORT}`);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user