mirror of
https://github.com/nodemailer/wildduck.git
synced 2025-03-04 03:45:19 +08:00
Updated account creation handlers
This commit is contained in:
parent
3068898bb8
commit
fcfff798e8
1 changed files with 16 additions and 1 deletions
|
@ -20,6 +20,9 @@ module.exports = (db, server, userHandler) => {
|
||||||
.alphanum()
|
.alphanum()
|
||||||
.lowercase()
|
.lowercase()
|
||||||
.max(128),
|
.max(128),
|
||||||
|
onlyAddresses: Joi.boolean()
|
||||||
|
.truthy(['Y', 'true', 'yes', 1])
|
||||||
|
.default(false),
|
||||||
limit: Joi.number()
|
limit: Joi.number()
|
||||||
.default(20)
|
.default(20)
|
||||||
.min(1)
|
.min(1)
|
||||||
|
@ -56,13 +59,25 @@ module.exports = (db, server, userHandler) => {
|
||||||
|
|
||||||
let filter = query
|
let filter = query
|
||||||
? {
|
? {
|
||||||
unameview: {
|
address: {
|
||||||
$regex: query.replace(/\./g, ''),
|
$regex: query.replace(/\./g, ''),
|
||||||
$options: ''
|
$options: ''
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
|
if (result.value.onlyAddresses) {
|
||||||
|
if (filter.address) {
|
||||||
|
filter.$and = [].concat(filter.$and || []).concat(filter.address);
|
||||||
|
delete filter.address;
|
||||||
|
filter.$and.push({
|
||||||
|
address: { $ne: '' }
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
filter.address = { $ne: '' };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
db.users.collection('users').count(filter, (err, total) => {
|
db.users.collection('users').count(filter, (err, total) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
res.json({
|
res.json({
|
||||||
|
|
Loading…
Reference in a new issue