feature(edit) add authCheck

This commit is contained in:
coderaiser 2016-07-14 21:12:48 +03:00
parent 1dc7698746
commit 32a59c0c26

View file

@ -49,11 +49,17 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format;
function(callback) {
loadFiles(element, callback);
},
function(callback) {
authCheck(editor);
callback();
},
function(callback) {
Edit.create(element)
.show(callback);
}, callback]);
},
callback
]);
}
function createElement() {
@ -119,6 +125,21 @@ var CloudCmd, Util, DOM, CloudFunc, MenuIO, Format;
return this;
};
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 getConfig(callback) {
DOM.Files.get('config', function(error, config) {
if (error)