feature(operation) add authCheck

This commit is contained in:
coderaiser 2016-07-14 21:17:03 +03:00
parent 5151f878f5
commit 3c3954139c

View file

@ -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);