mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
* Add some user lookup functionality
* Fix INTL to/from order * Remove VIA kludge when initially creating a NetMail message
This commit is contained in:
parent
e7109b0f0c
commit
84a1f70fc2
2 changed files with 42 additions and 4 deletions
38
core/user.js
38
core/user.js
|
@ -414,12 +414,48 @@ module.exports = class User {
|
|||
if(row) {
|
||||
return cb(null, row.id, row.user_name);
|
||||
}
|
||||
|
||||
|
||||
return cb(Errors.DoesNotExist('No matching username'));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static getUserIdAndNameByRealName(realName, cb) {
|
||||
userDb.get(
|
||||
`SELECT id, user_name
|
||||
FROM user
|
||||
WHERE id = (
|
||||
SELECT user_id
|
||||
FROM user_property
|
||||
WHERE prop_name='real_name' AND prop_value=?
|
||||
);`,
|
||||
[ realName ],
|
||||
(err, row) => {
|
||||
if(err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if(row) {
|
||||
return cb(null, row.id, row.user_name);
|
||||
}
|
||||
|
||||
return cb(Errors.DoesNotExist('No matching real name'));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static getUserIdAndNameByLookup(lookup, cb) {
|
||||
User.getUserIdAndName(lookup, (err, userId, userName) => {
|
||||
if(err) {
|
||||
User.getUserIdAndNameByRealName(lookup, (err, userId, userName) => {
|
||||
return cb(err, userId, userName);
|
||||
});
|
||||
} else {
|
||||
return cb(null, userId, userName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static getUserName(userId, cb) {
|
||||
userDb.get(
|
||||
`SELECT user_name
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue