added WebSockets API login

This commit is contained in:
cubedro 2015-02-26 23:55:39 +02:00
parent 5a75f389ad
commit 17e4fca9fd

7
app.js
View File

@ -42,6 +42,13 @@ api.on('connection', function(spark) {
console.log('got hello data from ', spark.id); console.log('got hello data from ', spark.id);
console.log(data); console.log(data);
if(typeof data.secret === 'undefined' || data.secret !== process.env.WS_SECRET)
{
spark.end(undefined, { reconnect: false });
return false;
}
if(typeof data.id !== 'undefined' && typeof data.info !== 'undefined') if(typeof data.id !== 'undefined' && typeof data.info !== 'undefined')
{ {
data.ip = spark.address.ip; data.ip = spark.address.ip;