From 3c3954139ccb50e8fc4248869d276457d57345ac Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Jul 2016 21:17:03 +0300 Subject: [PATCH] feature(operation) add authCheck --- lib/client/operation.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lib/client/operation.js b/lib/client/operation.js index 9c4fa245..db97b14a 100644 --- a/lib/client/operation.js +++ b/lib/client/operation.js @@ -59,6 +59,21 @@ ]); } + function authCheck(spawn) { + DOM.Files.get('config', function(error, config) { + if (error) + return Dialog.alert(TITLE, error); + + if (config.auth) { + spawn.emit('auth', config.username, config.password); + + spawn.on('auth', function() { + Dialog.alert(TITLE, 'Wrong credentials!'); + }); + } + }); + } + function create(prefix, callback) { exec.series([ function(fn) { @@ -66,6 +81,7 @@ fn(); copier.on('connect', function() { + authCheck(copier); copyFn = function(data, callback) { setListeners(copier, callback); copier.copy(data.from, data.to, data.names); @@ -82,6 +98,7 @@ remedy(prefix + '/remedy', prefix, function(remover) { fn(); remover.on('connect', function() { + authCheck(remover); deleteFn = function(from, files, callback) { from = from.replace(/\?.*/, ''); @@ -100,6 +117,7 @@ ishtar(prefix + '/ishtar', prefix, function(packer) { fn(); packer.on('connect', function() { + authCheck(packer); packFn = function(data, callback) { setListeners(packer, callback);