fixes
This commit is contained in:
parent
1e6975fa13
commit
0e4cc6507b
10
src/index.js
10
src/index.js
|
@ -35,7 +35,7 @@ wss.on('connection', (client) => {
|
||||||
let parsed = JSON.parse(message);
|
let parsed = JSON.parse(message);
|
||||||
let token = parsed.token;
|
let token = parsed.token;
|
||||||
let currentGroup = parsed.currentGroup;
|
let currentGroup = parsed.currentGroup;
|
||||||
|
try {
|
||||||
if (!jwt.verify(token, config.secret)) {
|
if (!jwt.verify(token, config.secret)) {
|
||||||
client.send("Invalid token");
|
client.send("Invalid token");
|
||||||
return;
|
return;
|
||||||
|
@ -45,6 +45,12 @@ wss.on('connection', (client) => {
|
||||||
client.send("Not a member of specified group");
|
client.send("Not a member of specified group");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log.error("Error during connection through websocket.")
|
||||||
|
client.send("Error")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
clients.push({
|
clients.push({
|
||||||
socket: client,
|
socket: client,
|
||||||
|
@ -69,7 +75,7 @@ const server = app.listen(config.port, () => {
|
||||||
|
|
||||||
server.on('upgrade', (req, res, head) => {
|
server.on('upgrade', (req, res, head) => {
|
||||||
wss.handleUpgrade(req, res, head, socket => {
|
wss.handleUpgrade(req, res, head, socket => {
|
||||||
wss.emit('connection', socket, request);
|
wss.emit('connection', socket, req);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue