aloux-iam 0.0.14 → 0.0.16
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.
- package/lib/controllers/user.js +14 -1
- package/lib/models/User.js +6 -1
- package/package.json +1 -1
package/lib/controllers/user.js
CHANGED
|
@@ -6,6 +6,8 @@ const jwt = require("jsonwebtoken")
|
|
|
6
6
|
const dayjs = require("dayjs")
|
|
7
7
|
const serviceUser = require('../services/user')
|
|
8
8
|
const utils = require('../config/utils')
|
|
9
|
+
const mongoose = require('mongoose');
|
|
10
|
+
|
|
9
11
|
const self = module.exports
|
|
10
12
|
|
|
11
13
|
|
|
@@ -56,8 +58,19 @@ self.updatepassword = async (req, resp) => {
|
|
|
56
58
|
self.get = async (req, res) => {
|
|
57
59
|
try {
|
|
58
60
|
const _id = req.params.USER_ID
|
|
61
|
+
let user = {}
|
|
62
|
+
|
|
63
|
+
// Valida que los modelos existan hantes de hacer una consulta con populate
|
|
64
|
+
if (mongoose.modelNames().includes('Business') && mongoose.modelNames().includes('Client')) {
|
|
65
|
+
user = await User.findOne({ _id }, { pwd: 0 }).populate([{ path: "_functions" },{ path: "_business" }, { path: "_client" }]).select("-pwd -tokens").lean()
|
|
66
|
+
}else if(mongoose.modelNames().includes('Business')){
|
|
67
|
+
user = await User.findOne({ _id }, { pwd: 0 }).populate([{ path: "_functions" },{ path: "_business" }]).select("-pwd -tokens").lean()
|
|
68
|
+
}else if(mongoose.modelNames().includes('Client')){
|
|
69
|
+
user = await User.findOne({ _id }, { pwd: 0 }).populate([{ path: "_functions" }, { path: "_client" }]).select("-pwd -tokens").lean()
|
|
70
|
+
} else{
|
|
71
|
+
user = await User.findOne({ _id }, { pwd: 0 }).populate([{ path: "_functions" }]).select("-pwd -tokens").lean()
|
|
72
|
+
}
|
|
59
73
|
|
|
60
|
-
const user = await User.findOne({ _id }, { pwd: 0 }).populate({ path: "_functions" }).select("-pwd -tokens").lean()
|
|
61
74
|
|
|
62
75
|
if (!user)
|
|
63
76
|
res.status(404).send()
|
package/lib/models/User.js
CHANGED