free-be-account 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +14 -12
  2. package/package.json +1 -1
  3. package/sms/index.js +2 -2
package/index.js CHANGED
@@ -1121,18 +1121,20 @@ module.exports = (app) => ({
1121
1121
  const phone = crypto.encoder.desDecode(req.body.PhoneNumber, m.config.desKey);
1122
1122
 
1123
1123
  // check user existance if necessary
1124
- const existsCount = await res.app.models.account.countDocuments({$or: [
1125
- { PhoneNumber: phone },
1126
- { 'Profile.Email': phone },
1127
- ]});
1128
-
1129
- if (req.body.exists && existsCount <= 0) {
1130
- res.makeError(409, 'User not exists!', m);
1131
- return next('route');
1132
- }
1133
- if (!req.body.exists && existsCount > 0) {
1134
- res.makeError(410, 'User aleady exists!', m);
1135
- return next('route');
1124
+ if (req.body.exists !== 'all') {
1125
+ const existsCount = await res.app.models.account.countDocuments({$or: [
1126
+ { PhoneNumber: phone },
1127
+ { 'Profile.Email': phone },
1128
+ ]});
1129
+
1130
+ if (req.body.exists && existsCount <= 0) {
1131
+ res.makeError(409, 'User not exists!', m);
1132
+ return next('route');
1133
+ }
1134
+ if (!req.body.exists && existsCount > 0) {
1135
+ res.makeError(410, 'User aleady exists!', m);
1136
+ return next('route');
1137
+ }
1136
1138
  }
1137
1139
 
1138
1140
  const result = await m.sms.sendRandom(phone, undefined, true, req.body.smsTemp || 'register');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-be-account",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "main": "index.js",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
package/sms/index.js CHANGED
@@ -5,8 +5,8 @@ const nodemailer = require('nodemailer');
5
5
 
6
6
  let global;
7
7
 
8
- if (fs.existsSync(path.resolve(__dirname, '../../global.js'))) {
9
- global = require('../../global');
8
+ if (fs.existsSync(path.resolve(__dirname, '../../../global.js'))) {
9
+ global = require('../../../global');
10
10
  }
11
11
 
12
12
  let MAIL_TRANS = undefined;