mirror of
https://github.com/NuSkooler/enigma-bbs.git
synced 2025-06-06 12:47:13 +02:00
* Rework user.js and User object to ES6
* Update download stats for user when web download is completed
This commit is contained in:
parent
6406d32165
commit
058ff3f367
14 changed files with 569 additions and 516 deletions
|
@ -2,7 +2,7 @@
|
|||
'use strict';
|
||||
|
||||
// ENiGMA½
|
||||
const user = require('./user.js');
|
||||
const User = require('./user.js');
|
||||
const Config = require('./config.js').config;
|
||||
|
||||
exports.validateNonEmpty = validateNonEmpty;
|
||||
|
@ -38,7 +38,7 @@ function validateUserNameAvail(data, cb) {
|
|||
} else if(/^[0-9]+$/.test(data)) {
|
||||
return cb(new Error('Username cannot be a number'));
|
||||
} else {
|
||||
user.getUserIdAndName(data, function userIdAndName(err) {
|
||||
User.getUserIdAndName(data, function userIdAndName(err) {
|
||||
if(!err) { // err is null if we succeeded -- meaning this user exists already
|
||||
return cb(new Error('Username unavailable'));
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ function validateUserNameExists(data, cb) {
|
|||
return cb(invalidUserNameError);
|
||||
}
|
||||
|
||||
user.getUserIdAndName(data, (err) => {
|
||||
User.getUserIdAndName(data, (err) => {
|
||||
return cb(err ? invalidUserNameError : null);
|
||||
});
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ function validateEmailAvail(data, cb) {
|
|||
return cb(new Error('Invalid email address'));
|
||||
}
|
||||
|
||||
user.getUserIdsWithProperty('email_address', data, function userIdsWithEmail(err, uids) {
|
||||
User.getUserIdsWithProperty('email_address', data, function userIdsWithEmail(err, uids) {
|
||||
if(err) {
|
||||
return cb(new Error('Internal system error'));
|
||||
} else if(uids.length > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue