extension/user.js
function (uid, token) {
		
		// TODO: check if local account already exists, or replace existing one
		
		// multiple accounts storable for one local server
		// NOTE: field name is a variable
		// ref: http://stackoverflow.com/questions/11133912/how-to-use-a-variable-as-a-field-name-in-mongodb-native-findandmodify		
		var field = 'data.accounts.' + server + '.' + uid;
		
		var onUpdated = function (error) {
			if (error) {
				var err = new Error("ADD_LOCAL_ACCOUNT_FAIL: " + account);
				err.name = "addLocal Error";
				err.code = 1;
				UTIL.safeCall(onDone, err);
			}
			else {
				UTIL.safeCall(onDone, null, {code: 0, msg: 'ADD_LOCAL_ACCOUNT_SUCCESS: ' + account});
			}
		};
		l_updateUser({account: account}, field, token, onUpdated);
	}
function (uid, token) {
		
		// TODO: check if local account already exists, or replace existing one
		
		// multiple accounts storable for one local server
		// NOTE: field name is a variable
		// ref: http://stackoverflow.com/questions/11133912/how-to-use-a-variable-as-a-field-name-in-mongodb-native-findandmodify		
		var field = 'data.accounts.' + server + '.' + uid;
		
		var onUpdated = function (error) {
			if (error) {
				var err = new Error("ADD_LOCAL_ACCOUNT_FAIL: " + account);
				err.name = "addLocal Error";
				err.code = 1;
				UTIL.safeCall(onDone, err);
			}
			else {
				UTIL.safeCall(onDone, null, {code: 0, msg: 'ADD_LOCAL_ACCOUNT_SUCCESS: ' + account});
			}
		};
		l_updateUser({account: account}, field, token, onUpdated);
	}
function ( uid , token ) { // TODO: check if local account already exists, or replace existing one // multiple accounts storable for one local server // NOTE: field name is a variable // ref: http://stackoverflow.com/questions/11133912/how-to-use-a-variable-as-a-field-name-in-mongodb-native-findandmodify		 var field = 'data.accounts.' + server + '.' + uid ; var onUpdated = function ( error ) { if ( error ) { var err = new Error ( "ADD_LOCAL_ACCOUNT_FAIL: " + account ) ; err . name = "addLocal Error" ; err . code = 1 ; UTIL . safeCall ( onDone , err ) ; } else { UTIL . safeCall ( onDone , null , { code : 0 , msg : 'ADD_LOCAL_ACCOUNT_SUCCESS: ' + account } ) ; } } ; l_updateUser ( { account : account } , field , token , onUpdated ) ; }
build callback to store local account if it's verified
build callback to store local account if it s verified