Files
servicedock/nodejs/sockets/index.js

32 lines
950 B
JavaScript
Raw Normal View History

module.exports = function(app, io, authentication) {
2016-09-20 15:00:00 +00:00
var docker = require('docker.js')(app, io);
2016-09-20 15:00:00 +00:00
// New Authenticated Client
2016-09-20 15:00:00 +00:00
function connection(socket, userdata) {
console.log("=> new connection from "+userdata.username);
docker.connect(socket);
2016-09-20 15:00:00 +00:00
}
// Handle Connection Authentication
2016-09-20 15:00:00 +00:00
require('socketio-auth')(io, {
authenticate: function (socket, data, callback) {
console.log("=> authenticate: ", data.username);
2016-09-20 22:29:33 +00:00
authentication(data.username, data.password,
function() {
console.log("####LOGIN-SUCESS####");
callback(null, true)
},
function() {
console.log("####LOGIN-FAIL####");
callback(new Error("wrong credentials"))
});
2016-09-20 15:00:00 +00:00
},
postAuthenticate: connection,
timeout: "none"
});
2016-01-22 15:50:21 +00:00
var module = {};
2016-09-20 15:00:00 +00:00
return module;
2016-01-14 15:34:50 +00:00
}