Fix events stuff, improve errors
This commit is contained in:
parent
3091c6dff6
commit
652fe5c264
6 changed files with 48 additions and 16 deletions
|
@ -65,16 +65,23 @@ export function* events() {
|
|||
let json;
|
||||
try{
|
||||
json = JSON.parse(message);
|
||||
} catch(e) {
|
||||
} catch(err) {
|
||||
debug('Invalid JSON for socket auth');
|
||||
this.websocket.send('Invalid authentication message. Bad JSON?');
|
||||
this.raven.captureError(err);
|
||||
}
|
||||
const reply = yield this.redis.get(json.authorization);
|
||||
if (reply) {
|
||||
pubsub.subscribe('/user/' + reply);
|
||||
debug('Subscribed to: /user/%s', reply);
|
||||
} else {
|
||||
this.websocket.send('Invalid authentication token.');
|
||||
try {
|
||||
const reply = yield this.redis.get(json.authorization);
|
||||
if (reply) {
|
||||
pubsub.subscribe('/user/' + reply);
|
||||
this.websocket.send('{"status":"active"}');
|
||||
debug('Subscribed to: /user/%s', reply);
|
||||
} else {
|
||||
this.websocket.send('Invalid authentication token.');
|
||||
}
|
||||
} catch(err) {
|
||||
debug(err);
|
||||
this.raven.captureError(err);
|
||||
}
|
||||
}.bind(this)));
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue