Yes! I'm going forward !
Now i can get getUserDataByField function work !
I needed :
var user = require.main.require('./src/user');
var userController = require.main.require('./src/controllers').user;
and call userController.getUserDataByField and not user.getUserDataByField
The bad notice is that it work if i use uid :
console.log(userObj.uid);
userController.getUserDataByField('1', 'uid', '13', function(err, userData) {
console.log(userData);
and it return :
46122
2018-11-27T20:45:39.706Z [12659] - verbose: [plugins/fireHook] {"meta":"filter:user.whitelistFields"}
2018-11-27T20:45:39.712Z [12659] - verbose: [plugins/fireHook] {"meta":"filter:users.get"}
2018-11-27T20:45:39.712Z [12659] - verbose: [plugins/fireHook] {"meta":"filter:user.getSettings"}
2018-11-27T20:45:39.713Z [12659] - verbose: [plugins/fireHook] {"meta":"filter:user.notificationTypes"}
{ uid: 13,
username: 'antani',
userslug: 'antani',
email: undefined,
'email:confirmed': 0,
joindate: 1542932961765,
lastonline: 1543323019093,
picture: '',
fullname: undefined,
location: '',
birthday: '',
website: '',
aboutme: null,
signature: '',
uploadedpicture: '',
profileviews: 0,
reputation: 0,
postcount: 0,
topiccount: 0,
lastposttime: 0,
banned: 0,
'banned:expire': 0,
status: 'offline',
flags: null,
followerCount: 0,
followingCount: 0,
'cover:url': null,
'cover:position': null,
groupTitle: null,
auid: '46122',
groupTitleArray: [],
'icon:text': 'A',
'icon:bgColor': '#2196f3',
joindateISO: '2018-11-23T00:29:21.765Z',
lastonlineISO: '2018-11-27T12:50:19.093Z',
banned_until: 0,
banned_until_readable: 'Not Banned' }
but not if i use :
console.log(userObj.uid);
userController.getUserDataByField('1', 'auid', userObj.uid, function(err, userData) {
console.log(userData);
it return null
46122
2018-11-27T20:41:57.152Z [12474] - verbose: [plugins/fireHook] {"meta":"filter:user.whitelistFields"}
2018-11-27T20:41:57.158Z [12474] - verbose: [plugins/fireHook] {"meta":"filter:users.get"}
2018-11-27T20:41:57.159Z [12474] - verbose: [plugins/fireHook] {"meta":"filter:user.getSettings"}
2018-11-27T20:41:57.160Z [12474] - verbose: [plugins/fireHook] {"meta":"filter:user.notificationTypes"}
{ uid: 0,
username: '[[global:former_user]]',
userslug: '',
email: undefined,
'email:confirmed': 0,
joindate: 0,
lastonline: 0,
picture: '',
fullname: undefined,
location: null,
birthday: null,
website: null,
aboutme: null,
signature: null,
uploadedpicture: null,
profileviews: 0,
reputation: 0,
postcount: 0,
topiccount: 0,
lastposttime: 0,
banned: 0,
'banned:expire': 0,
status: null,
flags: null,
followerCount: 0,
followingCount: 0,
'cover:url': null,
'cover:position': null,
groupTitle: '',
auid: null,
oldUid: 46122,
'icon:text': '?',
'icon:bgColor': '#aaa',
groupTitleArray: [],
joindateISO: '',
lastonlineISO: '',
banned_until: 0,
banned_until_readable: 'Not Banned' }
what's wrong now ? the field auid exist and is filled with the right value