handlers/login.js
function (err, result) {

		// if login is successful, we record the user's account in cache
		if (err) {
			LOG.warn(err.toString());
			result = {code: err.code, msg: err.message};
		}
		else {
			if (result.code === 0) {
				LOG.warn('login success, result: ');
				LOG.warn(result);

				var data = {
					account: user_data.account,
					groups: result.data.groups,
					lastStatus: result.data.lastStatus,
					permissions: []
				}
				
				l_initSession(event.data.login_id, event.session, data);

				/*
				// todo: read permssion from DB
				//event.session['_permissions'] = result.data.permissions;
				var xx = [];
				var onSuccess = function(dat){
					//console.log(dat.permission);
					if (dat === null) {
						console.log("no permission");
					}
					else {
						for (var i in dat.permission) {
							//console.log("pushing: " + dat.permission[i]);
							xx.push(dat.permission[i]);
						}
					}
					//event.done("get group", {"status": "success", "data": data});
				};
				var onFail = function(dat){
					//event.done("get group", {"status": "failure", "data": data});
				};
				for (var i in event.session['_groups']) {
					//console.log("getting: " + event.session['_groups'][i]);
					SR.DB.getData(groupPermissionDB, {"group": event.session['_groups'][i], part: "group"}, onSuccess, onFail);
				}
				*/
				
				// TODO: login at once to all local accounts
				// NOTE: need to query all local login account name & password, then perform individual logins
				l_login_local_accounts(user_data.account);			
			}
		}

		//LOG.warn('event before sending login response:');
		//LOG.warn(event);
		
		//if (result.data) delete result.data;
		// return response regardless success or fail
		event.done('SR_LOGIN_RESPONSE', result);
	}
function (err, result) {

		// if login is successful, we record the user's account in cache
		if (err) {
			LOG.warn(err.toString());
			result = {code: err.code, msg: err.message};
		}
		else {
			if (result.code === 0) {
				LOG.warn('login success, result: ');
				LOG.warn(result);

				var data = {
					account: user_data.account,
					groups: result.data.groups,
					lastStatus: result.data.lastStatus,
					permissions: []
				}
				
				l_initSession(event.data.login_id, event.session, data);

				/*
				// todo: read permssion from DB
				//event.session['_permissions'] = result.data.permissions;
				var xx = [];
				var onSuccess = function(dat){
					//console.log(dat.permission);
					if (dat === null) {
						console.log("no permission");
					}
					else {
						for (var i in dat.permission) {
							//console.log("pushing: " + dat.permission[i]);
							xx.push(dat.permission[i]);
						}
					}
					//event.done("get group", {"status": "success", "data": data});
				};
				var onFail = function(dat){
					//event.done("get group", {"status": "failure", "data": data});
				};
				for (var i in event.session['_groups']) {
					//console.log("getting: " + event.session['_groups'][i]);
					SR.DB.getData(groupPermissionDB, {"group": event.session['_groups'][i], part: "group"}, onSuccess, onFail);
				}
				*/
				
				// TODO: login at once to all local accounts
				// NOTE: need to query all local login account name & password, then perform individual logins
				l_login_local_accounts(user_data.account);			
			}
		}

		//LOG.warn('event before sending login response:');
		//LOG.warn(event);
		
		//if (result.data) delete result.data;
		// return response regardless success or fail
		event.done('SR_LOGIN_RESPONSE', result);
	}
function ( err , result ) { // if login is successful, we record the user's account in cache if ( err ) { LOG . warn ( err . toString ( ) ) ; result = { code : err . code , msg : err . message } ; } else { if ( result . code === 0 ) { LOG . warn ( 'login success, result: ' ) ; LOG . warn ( result ) ; var data = { account : user_data . account , groups : result . data . groups , lastStatus : result . data . lastStatus , permissions : [ ] } l_initSession ( event . data . login_id , event . session , data ) ; /*
				// todo: read permssion from DB
				//event.session['_permissions'] = result.data.permissions;
				var xx = [];
				var onSuccess = function(dat){
					//console.log(dat.permission);
					if (dat === null) {
						console.log("no permission");
					}
					else {
						for (var i in dat.permission) {
							//console.log("pushing: " + dat.permission[i]);
							xx.push(dat.permission[i]);
						}
					}
					//event.done("get group", {"status": "success", "data": data});
				};
				var onFail = function(dat){
					//event.done("get group", {"status": "failure", "data": data});
				};
				for (var i in event.session['_groups']) {
					//console.log("getting: " + event.session['_groups'][i]);
					SR.DB.getData(groupPermissionDB, {"group": event.session['_groups'][i], part: "group"}, onSuccess, onFail);
				}
				*/ // TODO: login at once to all local accounts // NOTE: need to query all local login account name & password, then perform individual logins l_login_local_accounts ( user_data . account ) ; } } //LOG.warn('event before sending login response:'); //LOG.warn(event); //if (result.data) delete result.data; // return response regardless success or fail event . done ( 'SR_LOGIN_RESPONSE' , result ) ; }
otherwise perform local login
otherwise perform local login