Authenticate websocket comms using user-provided token if present

Fixes #2642
This commit is contained in:
Nick O'Leary
2020-07-06 20:45:07 +01:00
parent 0243a902b2
commit 57154b2853
2 changed files with 45 additions and 2 deletions

View File

@@ -130,8 +130,16 @@ function CommsConnection(ws) {
}
});
} else {
log.audit({event: "comms.auth.fail"});
completeConnection(null,null,false);
Users.tokens(msg.auth).then(function(user) {
if (user) {
self.user = user;
log.audit({event: "comms.auth",user:self.user});
completeConnection(user.permissions,msg.auth,true);
} else {
log.audit({event: "comms.auth.fail"});
completeConnection(null,null,false);
}
});
}
});
} else {