mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
feature(cloudcmd) console: add authCheck
This commit is contained in:
parent
f4f3f65701
commit
63ebe53865
2 changed files with 27 additions and 2 deletions
|
|
@ -50,7 +50,19 @@
|
|||
function create(callback) {
|
||||
var prefix = getPrefix();
|
||||
|
||||
Console(Element, prefix, function() {
|
||||
Console(Element, prefix, function(spawn) {
|
||||
spawn.on('auth', function() {
|
||||
Dialog.alert(TITLE, 'Wrong credentials!');
|
||||
});
|
||||
|
||||
DOM.Files.get('config', function(error, config) {
|
||||
if (error)
|
||||
return Dialog.alert(TITLE, error);
|
||||
|
||||
if (config.auth)
|
||||
spawn.emit('auth', config.username, config.password);
|
||||
});
|
||||
|
||||
Util.exec(callback);
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -94,13 +94,26 @@
|
|||
return cloudcmd(prefix, p.socket);
|
||||
};
|
||||
|
||||
function authCheck(socket, success) {
|
||||
if (!config('auth'))
|
||||
return success();
|
||||
|
||||
socket.on('auth', function(name, pass) {
|
||||
name === config('username') &&
|
||||
pass === config('password') ?
|
||||
|
||||
success() : socket.emit('auth');
|
||||
});
|
||||
}
|
||||
|
||||
function listen(prefix, socket) {
|
||||
var size = cloudfunc.MAX_SIZE,
|
||||
pref = getPrefix(prefix);
|
||||
|
||||
webconsole({
|
||||
socket: socket,
|
||||
prefix: pref + '/console'
|
||||
prefix: pref + '/console',
|
||||
authCheck: authCheck
|
||||
});
|
||||
|
||||
edward.listen(socket, {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue