extension/user.js
function (account, data, conn) {

	//if (l_logins.hasOwnProperty(account) === true)
		//return false;
	
	// check if user's unique data exists
	if (typeof data.data !== 'object') {
		LOG.error('data field does not exist, cannot add login data');
		return false;
	}
	
	LOG.warn('account: ' + account + ' data:', 'addLogin');
	LOG.warn(data);
	
	// attach login name to connection
	// NOTE: we attach connection object to the data stored in memory (not clean?)
	if (conn) {
		// NOTE: we use session because this request could come from an HTTP request
		// that does not have a persistent connectino record in SR.Conn
		SR.Conn.setSessionName(conn, account);
		data._conn = conn;
	}
	
	l_logins[account] = data;
	LOG.warn('user [' + account + '] login success, total count: ' + Object.keys(l_logins).length, 'user');

	delete data._conn;
	//console.log(data);
	
	// error check: make sure lastStatus field exists
	if (data.hasOwnProperty('lastStatus') === false || data.lastStatus === null) 
		data.lastStatus = {loginCount: 0};
	
	data.lastStatus.loginIP = conn.host;
	data.lastStatus.loginCount = data.lastStatus.loginCount + 1;
	data.lastStatus.time = conn.time;

	SR.DB.updateData(SR.Settings.DB_NAME_ACCOUNT, {account: account}, data,
					 	function () {
					 	},
					 	function () {
					 	});	

	return true;
}
function (account, data, conn) {

	//if (l_logins.hasOwnProperty(account) === true)
		//return false;
	
	// check if user's unique data exists
	if (typeof data.data !== 'object') {
		LOG.error('data field does not exist, cannot add login data');
		return false;
	}
	
	LOG.warn('account: ' + account + ' data:', 'addLogin');
	LOG.warn(data);
	
	// attach login name to connection
	// NOTE: we attach connection object to the data stored in memory (not clean?)
	if (conn) {
		// NOTE: we use session because this request could come from an HTTP request
		// that does not have a persistent connectino record in SR.Conn
		SR.Conn.setSessionName(conn, account);
		data._conn = conn;
	}
	
	l_logins[account] = data;
	LOG.warn('user [' + account + '] login success, total count: ' + Object.keys(l_logins).length, 'user');

	delete data._conn;
	//console.log(data);
	
	// error check: make sure lastStatus field exists
	if (data.hasOwnProperty('lastStatus') === false || data.lastStatus === null) 
		data.lastStatus = {loginCount: 0};
	
	data.lastStatus.loginIP = conn.host;
	data.lastStatus.loginCount = data.lastStatus.loginCount + 1;
	data.lastStatus.time = conn.time;

	SR.DB.updateData(SR.Settings.DB_NAME_ACCOUNT, {account: account}, data,
					 	function () {
					 	},
					 	function () {
					 	});	

	return true;
}
function ( account , data , conn ) { //if (l_logins.hasOwnProperty(account) === true) //return false; // check if user's unique data exists if ( typeof data . data !== 'object' ) { LOG . error ( 'data field does not exist, cannot add login data' ) ; return false ; } LOG . warn ( 'account: ' + account + ' data:' , 'addLogin' ) ; LOG . warn ( data ) ; // attach login name to connection // NOTE: we attach connection object to the data stored in memory (not clean?) if ( conn ) { // NOTE: we use session because this request could come from an HTTP request // that does not have a persistent connectino record in SR.Conn SR . Conn . setSessionName ( conn , account ) ; data . _conn = conn ; } l_logins [ account ] = data ; LOG . warn ( 'user [' + account + '] login success, total count: ' + Object . keys ( l_logins ) . length , 'user' ) ; delete data . _conn ; //console.log(data); // error check: make sure lastStatus field exists if ( data . hasOwnProperty ( 'lastStatus' ) === false || data . lastStatus === null ) data . lastStatus = { loginCount : 0 } ; data . lastStatus . loginIP = conn . host ; data . lastStatus . loginCount = data . lastStatus . loginCount + 1 ; data . lastStatus . time = conn . time ; SR . DB . updateData ( SR . Settings . DB_NAME_ACCOUNT , { account : account } , data , function ( ) { } , function ( ) { } ) ; return true ; }
store & remove user data to cache
store & remove user data to cache