aloux-iam 0.0.122 → 0.0.124
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/auth.js +143 -129
- package/lib/controllers/business.js +3 -1
- package/lib/controllers/company.js +6 -5
- package/lib/controllers/log.js +20 -18
- package/lib/controllers/user.js +21 -1
- package/lib/models/Company.js +2 -1
- package/lib/models/Log.js +2 -1
- package/lib/router.js +7 -0
- package/lib/services/auth.js +8 -0
- package/package.json +1 -1
package/lib/controllers/auth.js
CHANGED
|
@@ -1,166 +1,180 @@
|
|
|
1
|
-
const Auth = require(
|
|
2
|
-
const utils = require(
|
|
1
|
+
const Auth = require("../services/auth");
|
|
2
|
+
const utils = require("../config/utils");
|
|
3
3
|
|
|
4
|
-
const self = module.exports
|
|
4
|
+
const self = module.exports;
|
|
5
5
|
|
|
6
6
|
self.email = async (req, res) => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
try {
|
|
8
|
+
const response = await Auth.searchEmail(req.body.email, req.body.code);
|
|
9
|
+
res.status(response.statusCode).send({
|
|
10
|
+
email: response.email,
|
|
11
|
+
_id: response._id,
|
|
12
|
+
name: response.name,
|
|
13
|
+
lastName: response.lastName,
|
|
14
|
+
});
|
|
15
|
+
} catch (error) {
|
|
16
|
+
await utils.responseError(res, error);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
14
19
|
|
|
15
20
|
self.login = async (req, res) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
21
|
+
try {
|
|
22
|
+
const response = await Auth.login(req.body, res);
|
|
23
|
+
res.status(200).send(response);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
await utils.responseError(res, error);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
self.logo = async (req, res) => {
|
|
30
|
+
try {
|
|
31
|
+
const response = await Auth.logo(req.body.email);
|
|
32
|
+
res.status(200).send(response);
|
|
33
|
+
} catch (error) {
|
|
34
|
+
await utils.responseError(res, error);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
23
37
|
|
|
24
38
|
self.logout = async (req, res) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
39
|
+
try {
|
|
40
|
+
await Auth.logout(req, res);
|
|
41
|
+
res.status(200).send();
|
|
42
|
+
} catch (error) {
|
|
43
|
+
await utils.responseError(res, error);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
32
46
|
|
|
33
47
|
self.logoutAll = async (req, res) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
48
|
+
try {
|
|
49
|
+
await Auth.logoutAll(req.body);
|
|
50
|
+
res.status(200).send();
|
|
51
|
+
} catch (error) {
|
|
52
|
+
await utils.responseError(res, error);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
41
55
|
|
|
42
56
|
self.me = async (req, res) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
57
|
+
try {
|
|
58
|
+
const response = await Auth.me(req, res);
|
|
59
|
+
res.status(200).send(response);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
await utils.responseError(res, error);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
50
64
|
|
|
51
65
|
self.resetPass = async (req, res) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
66
|
+
try {
|
|
67
|
+
const response = await Auth.resetPass(req, res);
|
|
68
|
+
res.status(200).send(response);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
await utils.responseError(res, error);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
59
73
|
|
|
60
74
|
self.updateAny = async (req, res) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
75
|
+
try {
|
|
76
|
+
const response = await Auth.updateAny(req, res);
|
|
77
|
+
res.status(200).send(response);
|
|
78
|
+
} catch (error) {
|
|
79
|
+
await utils.responseError(res, error);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
68
82
|
|
|
69
83
|
self.recoverpassword = async (req, res) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
84
|
+
try {
|
|
85
|
+
await Auth.recoverpassword(req, res);
|
|
86
|
+
res.status(200).send();
|
|
87
|
+
} catch (error) {
|
|
88
|
+
await utils.responseError(res, error);
|
|
89
|
+
}
|
|
90
|
+
};
|
|
77
91
|
|
|
78
92
|
self.verifyCode = async (req, res) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
93
|
+
try {
|
|
94
|
+
const response = await Auth.verifyCode(req, res);
|
|
95
|
+
res.status(200).send(response);
|
|
96
|
+
} catch (error) {
|
|
97
|
+
await utils.responseError(res, error);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
86
100
|
|
|
87
101
|
self.resetPassword = async (req, res) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
102
|
+
try {
|
|
103
|
+
const response = await Auth.resetPassword(req, res);
|
|
104
|
+
res.status(200).send(response);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
await utils.responseError(res, error);
|
|
107
|
+
}
|
|
108
|
+
};
|
|
95
109
|
|
|
96
110
|
self.sendVerifyMailAccount = async (req, res) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
111
|
+
try {
|
|
112
|
+
await Auth.sendVerifyMailAccountJob(req, true);
|
|
113
|
+
res.status(200).send();
|
|
114
|
+
} catch (error) {
|
|
115
|
+
await utils.responseError(res, error);
|
|
116
|
+
}
|
|
117
|
+
};
|
|
104
118
|
|
|
105
119
|
self.verifyMailTokenAccount = async (req, res) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
120
|
+
try {
|
|
121
|
+
const response = await Auth.verifyMailTokenAccount(req, res);
|
|
122
|
+
res.status(200).send(response);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
await utils.responseError(res, error);
|
|
125
|
+
}
|
|
126
|
+
};
|
|
113
127
|
|
|
114
128
|
self.updatePicture = async (req, res) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
129
|
+
try {
|
|
130
|
+
const response = await Auth.updatePicture(req, res);
|
|
131
|
+
res.status(202).send(response);
|
|
132
|
+
} catch (error) {
|
|
133
|
+
await utils.responseError(res, error);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
122
136
|
|
|
123
137
|
self.verifyPhone = async (req, res) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
138
|
+
try {
|
|
139
|
+
await Auth.verifyPhone(req, res);
|
|
140
|
+
res.status(200).send();
|
|
141
|
+
} catch (error) {
|
|
142
|
+
await utils.responseError(res, error);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
131
145
|
|
|
132
146
|
self.validatePhone = async (req, res) => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
147
|
+
try {
|
|
148
|
+
const response = await Auth.validatePhone(req, res);
|
|
149
|
+
res.status(200).send(response);
|
|
150
|
+
} catch (error) {
|
|
151
|
+
await utils.responseError(res, error);
|
|
152
|
+
}
|
|
153
|
+
};
|
|
140
154
|
|
|
141
155
|
self.createCustomer = async (req, res) => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
156
|
+
try {
|
|
157
|
+
let token = await Auth.createCustomer(req, res);
|
|
158
|
+
res.status(201).send(token);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
await utils.responseError(res, error);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
149
163
|
|
|
150
164
|
self.mailChange = async (req, res) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
165
|
+
try {
|
|
166
|
+
await Auth.mailChange(req.body.email, req.user);
|
|
167
|
+
res.status(200).send({ message: "Revisa el correo" });
|
|
168
|
+
} catch (error) {
|
|
169
|
+
await utils.responseError(res, error);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
158
172
|
|
|
159
173
|
self.validatEmailChange = async (req, res) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
174
|
+
try {
|
|
175
|
+
await Auth.validateCode(req, res);
|
|
176
|
+
res.status(200).send({ message: "Código correcto" });
|
|
177
|
+
} catch (error) {
|
|
178
|
+
await utils.responseError(res, error);
|
|
179
|
+
}
|
|
180
|
+
};
|
|
@@ -28,7 +28,9 @@ self.create = async (req, res) => {
|
|
|
28
28
|
|
|
29
29
|
self.retrieve = async (req, res) => {
|
|
30
30
|
try {
|
|
31
|
-
const retrieve = await Business.find({}, { gkey: 0 })
|
|
31
|
+
const retrieve = await Business.find({}, { gkey: 0 })
|
|
32
|
+
.populate("_company")
|
|
33
|
+
.lean();
|
|
32
34
|
res.status(200).send(retrieve);
|
|
33
35
|
} catch (error) {
|
|
34
36
|
await errorController.responseError(res, error);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const Company = require("../models/Company");
|
|
2
|
-
const
|
|
2
|
+
const AlouxAWS = require("./operationsAWS");
|
|
3
3
|
const errorController = require("../config/utils");
|
|
4
4
|
const self = module.exports;
|
|
5
5
|
|
|
@@ -104,10 +104,11 @@ self.picture = async (req, res) => {
|
|
|
104
104
|
);
|
|
105
105
|
|
|
106
106
|
company.imgUrl = imgUrl;
|
|
107
|
-
const
|
|
107
|
+
const updateCompany = await company.save();
|
|
108
108
|
|
|
109
|
-
res.status(202).send(
|
|
109
|
+
res.status(202).send(updateCompany);
|
|
110
110
|
} catch (error) {
|
|
111
|
+
console.error(error);
|
|
111
112
|
res.status(400).send({ error: error.message });
|
|
112
113
|
}
|
|
113
114
|
};
|
|
@@ -122,9 +123,9 @@ self.favicon = async (req, res) => {
|
|
|
122
123
|
);
|
|
123
124
|
|
|
124
125
|
company.faviconUrl = faviconUrl;
|
|
125
|
-
const
|
|
126
|
+
const updateCompany = await company.save();
|
|
126
127
|
|
|
127
|
-
res.status(202).send(
|
|
128
|
+
res.status(202).send(updateCompany);
|
|
128
129
|
} catch (error) {
|
|
129
130
|
res.status(400).send({ error: error.message });
|
|
130
131
|
}
|
package/lib/controllers/log.js
CHANGED
|
@@ -4,18 +4,16 @@ const self = module.exports;
|
|
|
4
4
|
|
|
5
5
|
self.create = async (req, res) => {
|
|
6
6
|
try {
|
|
7
|
+
const companyId =
|
|
8
|
+
req.header("Company") !== "undefined" ? req.header("Company") : null;
|
|
9
|
+
|
|
7
10
|
const log = new Log(req.body);
|
|
8
11
|
log.createdAt = new Date().getTime();
|
|
9
12
|
log._user = req.user._id;
|
|
10
|
-
|
|
11
|
-
{ label: req.body.label },
|
|
12
|
-
{ _id: 1 }
|
|
13
|
-
).lean();
|
|
14
|
-
if (label) {
|
|
15
|
-
log._label = label._id;
|
|
16
|
-
await log.save();
|
|
17
|
-
}
|
|
13
|
+
log._company = companyId;
|
|
18
14
|
|
|
15
|
+
log.label = req.body.label;
|
|
16
|
+
await log.save();
|
|
19
17
|
res.status(201).send(log);
|
|
20
18
|
} catch (error) {
|
|
21
19
|
res.status(400).send({ error: error.message });
|
|
@@ -50,7 +48,9 @@ self.status = async (req, resp) => {
|
|
|
50
48
|
};
|
|
51
49
|
self.retrieve = async (req, res) => {
|
|
52
50
|
try {
|
|
53
|
-
|
|
51
|
+
const companyId =
|
|
52
|
+
req.header("Company") !== "undefined" ? req.header("Company") : null;
|
|
53
|
+
let query = { _company: companyId };
|
|
54
54
|
|
|
55
55
|
if (req.body.users.length) {
|
|
56
56
|
query = {
|
|
@@ -59,15 +59,17 @@ self.retrieve = async (req, res) => {
|
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
const consulta = await Log.find(query)
|
|
62
|
-
.populate([
|
|
63
|
-
{ path: "_label" },
|
|
64
|
-
{ path: "_user", select: { name: 1, lastName: 1 } },
|
|
65
|
-
])
|
|
62
|
+
.populate([{ path: "_user", select: { name: 1, lastName: 1 } }])
|
|
66
63
|
.sort({ createdAt: 1 })
|
|
67
64
|
.lean();
|
|
68
65
|
|
|
66
|
+
// for (let i in consulta) {
|
|
67
|
+
// consulta[i].label = consulta[i]._label.label;
|
|
68
|
+
// await consulta[i].save();
|
|
69
|
+
// }
|
|
70
|
+
|
|
69
71
|
const response = {
|
|
70
|
-
dataset0: { field: "
|
|
72
|
+
dataset0: { field: "Visualizaciones totales", count: consulta.length },
|
|
71
73
|
dataset1: processDataset1(consulta),
|
|
72
74
|
dataset2: processDataset2(consulta),
|
|
73
75
|
dataset3: processDataset3(consulta),
|
|
@@ -108,7 +110,7 @@ function processDataset1(consulta) {
|
|
|
108
110
|
return consulta.map((item) => {
|
|
109
111
|
return {
|
|
110
112
|
_id: item._id,
|
|
111
|
-
labelDescription: item.
|
|
113
|
+
labelDescription: item.label,
|
|
112
114
|
userName: item._user.name + " " + item._user.lastName,
|
|
113
115
|
createdAt: item.createdAt,
|
|
114
116
|
};
|
|
@@ -117,7 +119,7 @@ function processDataset1(consulta) {
|
|
|
117
119
|
|
|
118
120
|
function processDataset2(consulta) {
|
|
119
121
|
const labelCounts = consulta.reduce((acc, item) => {
|
|
120
|
-
const label = item.
|
|
122
|
+
const label = item.label;
|
|
121
123
|
acc[label] = (acc[label] || 0) + 1;
|
|
122
124
|
return acc;
|
|
123
125
|
}, {});
|
|
@@ -131,7 +133,7 @@ function processDataset2(consulta) {
|
|
|
131
133
|
|
|
132
134
|
function processDataset3(consulta) {
|
|
133
135
|
const labelCounts = consulta.reduce((acc, item) => {
|
|
134
|
-
const label = item.
|
|
136
|
+
const label = item.label;
|
|
135
137
|
acc[label] = (acc[label] || 0) + 1;
|
|
136
138
|
return acc;
|
|
137
139
|
}, {});
|
|
@@ -165,7 +167,7 @@ function processDataset5(consulta) {
|
|
|
165
167
|
|
|
166
168
|
consulta.forEach((item) => {
|
|
167
169
|
const date = formatDate(new Date(item.createdAt));
|
|
168
|
-
const label = item.
|
|
170
|
+
const label = item.label;
|
|
169
171
|
categories.add(date);
|
|
170
172
|
|
|
171
173
|
if (!labelCountsByDate[date]) {
|
package/lib/controllers/user.js
CHANGED
|
@@ -165,7 +165,7 @@ self.retrieveByBusiness = async (req, res) => {
|
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
let result = await User.find({ _business: business._id })
|
|
168
|
-
.select(
|
|
168
|
+
.select({ name: 1, lastName: 1, _functions: 1, email: 1 })
|
|
169
169
|
.populate({ path: "_functions", select: { name: 1 } })
|
|
170
170
|
.sort({ createdAt: -1 })
|
|
171
171
|
.lean();
|
|
@@ -176,6 +176,26 @@ self.retrieveByBusiness = async (req, res) => {
|
|
|
176
176
|
}
|
|
177
177
|
};
|
|
178
178
|
|
|
179
|
+
self.retrieveByMyCompanies = async (req, res) => {
|
|
180
|
+
try {
|
|
181
|
+
const companies = req.user._company || [];
|
|
182
|
+
|
|
183
|
+
let result = await User.find({ _company: { $in: companies } })
|
|
184
|
+
.select("-pwd -tokens")
|
|
185
|
+
.populate([
|
|
186
|
+
{ path: "_functions", select: { name: 1 } },
|
|
187
|
+
{ path: "_company" },
|
|
188
|
+
{ path: "_business" },
|
|
189
|
+
])
|
|
190
|
+
.sort({ createdAt: -1 })
|
|
191
|
+
.lean();
|
|
192
|
+
|
|
193
|
+
res.status(200).send(result);
|
|
194
|
+
} catch (error) {
|
|
195
|
+
res.status(400).send({ error: error.message });
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
|
|
179
199
|
self.delete = async (req, res) => {
|
|
180
200
|
try {
|
|
181
201
|
const _id = req.params.USER_ID;
|
package/lib/models/Company.js
CHANGED
|
@@ -4,7 +4,8 @@ const businessSchema = mongoose.Schema({
|
|
|
4
4
|
name: { type: String, required: true, trim: true, maxLength: 200 },
|
|
5
5
|
imgUrl: { type: String, required: false, trim: true, maxLength: 500 },
|
|
6
6
|
data: { type: Object, required: false },
|
|
7
|
-
|
|
7
|
+
imgUrl: { type: String, required: false, trim: true, maxLength: 500 },
|
|
8
|
+
faviconUrl: { type: String, required: false },
|
|
8
9
|
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
9
10
|
createdAt: { type: Number },
|
|
10
11
|
lastUpdate: { type: Number },
|
package/lib/models/Log.js
CHANGED
|
@@ -2,8 +2,9 @@ const mongoose = require("mongoose");
|
|
|
2
2
|
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
3
3
|
|
|
4
4
|
const menuSchema = mongoose.Schema({
|
|
5
|
-
|
|
5
|
+
label: { type: String, required: true },
|
|
6
6
|
_user: { type: ObjectId, required: true, ref: "User" },
|
|
7
|
+
_company: { type: ObjectId, required: false, ref: "Company" },
|
|
7
8
|
createdAt: { type: Number },
|
|
8
9
|
});
|
|
9
10
|
|
package/lib/router.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const express = require("express");
|
|
2
2
|
const middleware = require("./middleware.js");
|
|
3
3
|
const router = express.Router();
|
|
4
|
+
const fileupload = require("express-fileupload");
|
|
5
|
+
router.use(fileupload());
|
|
4
6
|
|
|
5
7
|
const auth = require("./controllers/auth");
|
|
6
8
|
const user = require("./controllers/user");
|
|
@@ -17,6 +19,7 @@ const history = require("./controllers/history.js");
|
|
|
17
19
|
// User / user self (no auth)
|
|
18
20
|
router.post("/iam/auth/email", auth.email);
|
|
19
21
|
router.post("/iam/auth/login", auth.login);
|
|
22
|
+
router.post("/iam/auth/logo", auth.logo);
|
|
20
23
|
router.post("/iam/auth/forgot/password", auth.recoverpassword);
|
|
21
24
|
router.post("/iam/auth/validate/code", auth.verifyCode);
|
|
22
25
|
router.post("/iam/auth/verify/mail", auth.sendVerifyMailAccount);
|
|
@@ -39,6 +42,7 @@ router.post("/iam/auth/validate/mail", middleware, auth.validatEmailChange);
|
|
|
39
42
|
router.post("/iam/user", middleware, user.create);
|
|
40
43
|
router.get("/iam/user", middleware, user.retrieve);
|
|
41
44
|
router.get("/iam/business/user", middleware, user.retrieveByBusiness);
|
|
45
|
+
router.get("/iam/user/by/my/companies", middleware, user.retrieveByMyCompanies);
|
|
42
46
|
router.get("/iam/user/:USER_ID", middleware, user.get);
|
|
43
47
|
router.patch("/iam/user/:USER_ID", middleware, user.update);
|
|
44
48
|
router.put("/iam/user/:USER_ID/status", middleware, user.status);
|
|
@@ -139,4 +143,7 @@ router.patch("/iam/company/:COMPANY_ID/picture", middleware, company.picture);
|
|
|
139
143
|
router.patch("/iam/company/:COMPANY_ID/favicon", middleware, company.favicon);
|
|
140
144
|
router.get("/iam/company/:ID/identity", company.identity);
|
|
141
145
|
|
|
146
|
+
router.patch("/iam/company/:COMPANY_ID/picture", middleware, business.picture);
|
|
147
|
+
router.patch("/iam/company/:COMPANY_ID/favicon", middleware, business.favicon);
|
|
148
|
+
|
|
142
149
|
module.exports = router;
|
package/lib/services/auth.js
CHANGED
|
@@ -205,6 +205,14 @@ self.login = async (body, res) => {
|
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
self.logo = async (email) => {
|
|
209
|
+
const user = await User.findOne({ email: email }).populate("_company").lean();
|
|
210
|
+
if (user._company.length === 1) {
|
|
211
|
+
return { logo: user._company[0].imgUrl };
|
|
212
|
+
}
|
|
213
|
+
return null;
|
|
214
|
+
};
|
|
215
|
+
|
|
208
216
|
self.logout = async (req, res) => {
|
|
209
217
|
const user = await User.findOne({ _id: req.user._id });
|
|
210
218
|
user.tokens = user.tokens.filter((token) => {
|