mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(operation) add authCheck
This commit is contained in:
parent
5151f878f5
commit
3c3954139c
1 changed files with 18 additions and 0 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue