Lookup username and real name in various scenarios
This commit is contained in:
parent
f967ce1ce6
commit
ab12fb5d79
|
@ -413,13 +413,13 @@ exports.FullScreenEditorModule = exports.getModule = class FullScreenEditorModul
|
||||||
function populateLocalUserInfo(callback) {
|
function populateLocalUserInfo(callback) {
|
||||||
if(self.isPrivateMail()) {
|
if(self.isPrivateMail()) {
|
||||||
self.message.setLocalFromUserId(self.client.user.userId);
|
self.message.setLocalFromUserId(self.client.user.userId);
|
||||||
|
|
||||||
if(self.toUserId > 0) {
|
if(self.toUserId > 0) {
|
||||||
self.message.setLocalToUserId(self.toUserId);
|
self.message.setLocalToUserId(self.toUserId);
|
||||||
callback(null);
|
callback(null);
|
||||||
} else {
|
} else {
|
||||||
// we need to look it up
|
// we need to look it up
|
||||||
User.getUserIdAndName(self.message.toUserName, function userInfo(err, toUserId) {
|
User.getUserIdAndNameByLookup(self.message.toUserName, function userInfo(err, toUserId) {
|
||||||
if(err) {
|
if(err) {
|
||||||
callback(err);
|
callback(err);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -112,7 +112,7 @@ Message.FtnPropertyNames = {
|
||||||
FtnDestZone : 'ftn_dest_zone',
|
FtnDestZone : 'ftn_dest_zone',
|
||||||
FtnOrigPoint : 'ftn_orig_point',
|
FtnOrigPoint : 'ftn_orig_point',
|
||||||
FtnDestPoint : 'ftn_dest_point',
|
FtnDestPoint : 'ftn_dest_point',
|
||||||
|
|
||||||
FtnAttribute : 'ftn_attribute',
|
FtnAttribute : 'ftn_attribute',
|
||||||
|
|
||||||
FtnTearLine : 'ftn_tear_line', // http://ftsc.org/docs/fts-0004.001
|
FtnTearLine : 'ftn_tear_line', // http://ftsc.org/docs/fts-0004.001
|
||||||
|
|
|
@ -55,7 +55,7 @@ function areaFix() {
|
||||||
const User = require('../user.js');
|
const User = require('../user.js');
|
||||||
|
|
||||||
if(argv.from) {
|
if(argv.from) {
|
||||||
User.getUserIdAndName(argv.from, (err, userId, fromName) => {
|
User.getUserIdAndNameByLookup(argv.from, (err, userId, fromName) => {
|
||||||
if(err) {
|
if(err) {
|
||||||
return callback(null, ftnAddr, argv.from, 0);
|
return callback(null, ftnAddr, argv.from, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,14 @@ const Log = require('./logger.js').log;
|
||||||
// deps
|
// deps
|
||||||
const fs = require('graceful-fs');
|
const fs = require('graceful-fs');
|
||||||
|
|
||||||
exports.validateNonEmpty = validateNonEmpty;
|
exports.validateNonEmpty = validateNonEmpty;
|
||||||
exports.validateMessageSubject = validateMessageSubject;
|
exports.validateMessageSubject = validateMessageSubject;
|
||||||
exports.validateUserNameAvail = validateUserNameAvail;
|
exports.validateUserNameAvail = validateUserNameAvail;
|
||||||
exports.validateUserNameExists = validateUserNameExists;
|
exports.validateUserNameExists = validateUserNameExists;
|
||||||
exports.validateEmailAvail = validateEmailAvail;
|
exports.validateUserNameOrRealNameExists = validateUserNameOrRealNameExists;
|
||||||
exports.validateBirthdate = validateBirthdate;
|
exports.validateEmailAvail = validateEmailAvail;
|
||||||
exports.validatePasswordSpec = validatePasswordSpec;
|
exports.validateBirthdate = validateBirthdate;
|
||||||
|
exports.validatePasswordSpec = validatePasswordSpec;
|
||||||
|
|
||||||
function validateNonEmpty(data, cb) {
|
function validateNonEmpty(data, cb) {
|
||||||
return cb(data && data.length > 0 ? null : new Error('Field cannot be empty'));
|
return cb(data && data.length > 0 ? null : new Error('Field cannot be empty'));
|
||||||
|
@ -42,11 +43,12 @@ function validateUserNameAvail(data, cb) {
|
||||||
} else if(/^[0-9]+$/.test(data)) {
|
} else if(/^[0-9]+$/.test(data)) {
|
||||||
return cb(new Error('Username cannot be a number'));
|
return cb(new Error('Username cannot be a number'));
|
||||||
} else {
|
} else {
|
||||||
User.getUserIdAndName(data, function userIdAndName(err) {
|
// a new user name cannot be an existing user name or an existing real name
|
||||||
|
User.getUserIdAndNameByLookup(data, function userIdAndName(err) {
|
||||||
if(!err) { // err is null if we succeeded -- meaning this user exists already
|
if(!err) { // err is null if we succeeded -- meaning this user exists already
|
||||||
return cb(new Error('Username unavailable'));
|
return cb(new Error('Username unavailable'));
|
||||||
}
|
}
|
||||||
|
|
||||||
return cb(null);
|
return cb(null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -65,6 +67,18 @@ function validateUserNameExists(data, cb) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateUserNameOrRealNameExists(data, cb) {
|
||||||
|
const invalidUserNameError = new Error('Invalid username');
|
||||||
|
|
||||||
|
if(0 === data.length) {
|
||||||
|
return cb(invalidUserNameError);
|
||||||
|
}
|
||||||
|
|
||||||
|
User.getUserIdAndNameByLookup(data, err => {
|
||||||
|
return cb(err ? invalidUserNameError : null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function validateEmailAvail(data, cb) {
|
function validateEmailAvail(data, cb) {
|
||||||
//
|
//
|
||||||
// This particular method allows empty data - e.g. no email entered
|
// This particular method allows empty data - e.g. no email entered
|
||||||
|
|
2
main.js
2
main.js
|
@ -7,6 +7,6 @@
|
||||||
ENiGMA½ entry point
|
ENiGMA½ entry point
|
||||||
|
|
||||||
If this file does not run directly, ensure it's executable:
|
If this file does not run directly, ensure it's executable:
|
||||||
> chmod u+x main.js
|
> chmod u+x main.js
|
||||||
*/
|
*/
|
||||||
require('./core/bbs.js').main();
|
require('./core/bbs.js').main();
|
Loading…
Reference in New Issue