aloux-iam 0.0.121 → 0.0.123
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 +145 -129
- package/lib/controllers/business.js +4 -2
- 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 +10 -0
- package/package.json +1 -1
package/lib/controllers/auth.js
CHANGED
|
@@ -1,166 +1,182 @@
|
|
|
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
|
|
10
|
+
.status(response.statusCode)
|
|
11
|
+
.send({
|
|
12
|
+
email: response.email,
|
|
13
|
+
_id: response._id,
|
|
14
|
+
name: response.name,
|
|
15
|
+
lastName: response.lastName,
|
|
16
|
+
});
|
|
17
|
+
} catch (error) {
|
|
18
|
+
await utils.responseError(res, error);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
14
21
|
|
|
15
22
|
self.login = async (req, res) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
+
try {
|
|
24
|
+
const response = await Auth.login(req.body, res);
|
|
25
|
+
res.status(200).send(response);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
await utils.responseError(res, error);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
self.logo = async (req, res) => {
|
|
32
|
+
try {
|
|
33
|
+
const response = await Auth.logo(req.body, res);
|
|
34
|
+
res.status(200).send(response);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
await utils.responseError(res, error);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
23
39
|
|
|
24
40
|
self.logout = async (req, res) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
41
|
+
try {
|
|
42
|
+
await Auth.logout(req, res);
|
|
43
|
+
res.status(200).send();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
await utils.responseError(res, error);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
32
48
|
|
|
33
49
|
self.logoutAll = async (req, res) => {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
50
|
+
try {
|
|
51
|
+
await Auth.logoutAll(req.body);
|
|
52
|
+
res.status(200).send();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
await utils.responseError(res, error);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
41
57
|
|
|
42
58
|
self.me = async (req, res) => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
59
|
+
try {
|
|
60
|
+
const response = await Auth.me(req, res);
|
|
61
|
+
res.status(200).send(response);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
await utils.responseError(res, error);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
50
66
|
|
|
51
67
|
self.resetPass = async (req, res) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
68
|
+
try {
|
|
69
|
+
const response = await Auth.resetPass(req, res);
|
|
70
|
+
res.status(200).send(response);
|
|
71
|
+
} catch (error) {
|
|
72
|
+
await utils.responseError(res, error);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
59
75
|
|
|
60
76
|
self.updateAny = async (req, res) => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
77
|
+
try {
|
|
78
|
+
const response = await Auth.updateAny(req, res);
|
|
79
|
+
res.status(200).send(response);
|
|
80
|
+
} catch (error) {
|
|
81
|
+
await utils.responseError(res, error);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
68
84
|
|
|
69
85
|
self.recoverpassword = async (req, res) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
86
|
+
try {
|
|
87
|
+
await Auth.recoverpassword(req, res);
|
|
88
|
+
res.status(200).send();
|
|
89
|
+
} catch (error) {
|
|
90
|
+
await utils.responseError(res, error);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
77
93
|
|
|
78
94
|
self.verifyCode = async (req, res) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
95
|
+
try {
|
|
96
|
+
const response = await Auth.verifyCode(req, res);
|
|
97
|
+
res.status(200).send(response);
|
|
98
|
+
} catch (error) {
|
|
99
|
+
await utils.responseError(res, error);
|
|
100
|
+
}
|
|
101
|
+
};
|
|
86
102
|
|
|
87
103
|
self.resetPassword = async (req, res) => {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
104
|
+
try {
|
|
105
|
+
const response = await Auth.resetPassword(req, res);
|
|
106
|
+
res.status(200).send(response);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
await utils.responseError(res, error);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
95
111
|
|
|
96
112
|
self.sendVerifyMailAccount = async (req, res) => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
113
|
+
try {
|
|
114
|
+
await Auth.sendVerifyMailAccountJob(req, true);
|
|
115
|
+
res.status(200).send();
|
|
116
|
+
} catch (error) {
|
|
117
|
+
await utils.responseError(res, error);
|
|
118
|
+
}
|
|
119
|
+
};
|
|
104
120
|
|
|
105
121
|
self.verifyMailTokenAccount = async (req, res) => {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
122
|
+
try {
|
|
123
|
+
const response = await Auth.verifyMailTokenAccount(req, res);
|
|
124
|
+
res.status(200).send(response);
|
|
125
|
+
} catch (error) {
|
|
126
|
+
await utils.responseError(res, error);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
113
129
|
|
|
114
130
|
self.updatePicture = async (req, res) => {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
131
|
+
try {
|
|
132
|
+
const response = await Auth.updatePicture(req, res);
|
|
133
|
+
res.status(202).send(response);
|
|
134
|
+
} catch (error) {
|
|
135
|
+
await utils.responseError(res, error);
|
|
136
|
+
}
|
|
137
|
+
};
|
|
122
138
|
|
|
123
139
|
self.verifyPhone = async (req, res) => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
140
|
+
try {
|
|
141
|
+
await Auth.verifyPhone(req, res);
|
|
142
|
+
res.status(200).send();
|
|
143
|
+
} catch (error) {
|
|
144
|
+
await utils.responseError(res, error);
|
|
145
|
+
}
|
|
146
|
+
};
|
|
131
147
|
|
|
132
148
|
self.validatePhone = async (req, res) => {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
149
|
+
try {
|
|
150
|
+
const response = await Auth.validatePhone(req, res);
|
|
151
|
+
res.status(200).send(response);
|
|
152
|
+
} catch (error) {
|
|
153
|
+
await utils.responseError(res, error);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
140
156
|
|
|
141
157
|
self.createCustomer = async (req, res) => {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
158
|
+
try {
|
|
159
|
+
let token = await Auth.createCustomer(req, res);
|
|
160
|
+
res.status(201).send(token);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
await utils.responseError(res, error);
|
|
163
|
+
}
|
|
164
|
+
};
|
|
149
165
|
|
|
150
166
|
self.mailChange = async (req, res) => {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}
|
|
167
|
+
try {
|
|
168
|
+
await Auth.mailChange(req.body.email, req.user);
|
|
169
|
+
res.status(200).send({ message: "Revisa el correo" });
|
|
170
|
+
} catch (error) {
|
|
171
|
+
await utils.responseError(res, error);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
158
174
|
|
|
159
175
|
self.validatEmailChange = async (req, res) => {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
176
|
+
try {
|
|
177
|
+
await Auth.validateCode(req, res);
|
|
178
|
+
res.status(200).send({ message: "Código correcto" });
|
|
179
|
+
} catch (error) {
|
|
180
|
+
await utils.responseError(res, error);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
@@ -8,7 +8,7 @@ self.create = async (req, res) => {
|
|
|
8
8
|
try {
|
|
9
9
|
req.body.createdAt = new Date().getTime();
|
|
10
10
|
req.body.lastUpdate = req.body.createdAt;
|
|
11
|
-
req.body.status = "
|
|
11
|
+
req.body.status = "Activo";
|
|
12
12
|
|
|
13
13
|
if (req.body.environment && req.body.environment.length > 1) {
|
|
14
14
|
for (let i in req.body.environment) {
|
|
@@ -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,16 @@ self.login = async (body, res) => {
|
|
|
205
205
|
}
|
|
206
206
|
};
|
|
207
207
|
|
|
208
|
+
self.logo = async (body, res) => {
|
|
209
|
+
const user = await User.findOne({ _id: req.user._id })
|
|
210
|
+
.populate("_company")
|
|
211
|
+
.lean();
|
|
212
|
+
if (user._company.length === 1) {
|
|
213
|
+
return { logo: user._company[0].imgUrl };
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
};
|
|
217
|
+
|
|
208
218
|
self.logout = async (req, res) => {
|
|
209
219
|
const user = await User.findOne({ _id: req.user._id });
|
|
210
220
|
user.tokens = user.tokens.filter((token) => {
|