aloux-iam 0.0.117 → 0.0.118
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/.gitattributes +2 -2
- package/CONTRIBUTING.md +1 -1
- package/LICENSE +21 -21
- package/README.md +271 -271
- package/index.js +38 -38
- package/lib/config/utils.js +13 -13
- package/lib/controllers/auth.js +166 -166
- package/lib/controllers/business.js +203 -0
- package/lib/controllers/company.js +154 -0
- package/lib/controllers/functions.js +86 -86
- package/lib/controllers/history.js +97 -97
- package/lib/controllers/label.js +82 -82
- package/lib/controllers/log.js +278 -268
- package/lib/controllers/menu.js +101 -101
- package/lib/controllers/operationsAWS.js +228 -228
- package/lib/controllers/permission.js +90 -90
- package/lib/controllers/user.js +880 -880
- package/lib/middleware.js +148 -146
- package/lib/models/Business.js +48 -14
- package/lib/models/Company.js +14 -0
- package/lib/models/Functions.js +13 -13
- package/lib/models/History.js +15 -15
- package/lib/models/Label.js +13 -13
- package/lib/models/Log.js +11 -11
- package/lib/models/Menu.js +17 -17
- package/lib/models/Permission.js +16 -16
- package/lib/models/User.js +136 -115
- package/lib/models/UserProvisional.js +10 -10
- package/lib/router.js +142 -104
- package/lib/services/auth.js +958 -958
- package/lib/services/bigQuery.js +87 -87
- package/lib/services/s3.js +71 -71
- package/lib/services/ses.js +97 -97
- package/lib/services/sns.js +21 -21
- package/lib/services/user.js +99 -99
- package/lib/swagger.yaml +1231 -1231
- package/package.json +38 -38
package/lib/services/user.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
const User = require('../models/User')
|
|
2
|
-
const self = module.exports
|
|
3
|
-
|
|
4
|
-
self.create = async (body) => {
|
|
5
|
-
let user
|
|
6
|
-
user = await User.findOne({email: body.email}).lean()
|
|
7
|
-
|
|
8
|
-
if(user){
|
|
9
|
-
throw {
|
|
10
|
-
code: 404,
|
|
11
|
-
title: 'Upss!',
|
|
12
|
-
detail: '',
|
|
13
|
-
suggestion: 'El correo ya se encuentra resgitrado',
|
|
14
|
-
error: new Error()
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
user = new User(body)
|
|
19
|
-
user.createdAt = (new Date()).getTime()
|
|
20
|
-
user.status = body?.status ? body?.status : 'Activo'
|
|
21
|
-
|
|
22
|
-
delete user.pwd
|
|
23
|
-
user.data.changePwd = false
|
|
24
|
-
await user.save()
|
|
25
|
-
|
|
26
|
-
return user
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
self.update = async (USER_ID, body) => {
|
|
30
|
-
const _id = USER_ID
|
|
31
|
-
const user = await User.findOne({ _id }).countDocuments().lean()
|
|
32
|
-
|
|
33
|
-
if (!user) {
|
|
34
|
-
throw {
|
|
35
|
-
code: 404,
|
|
36
|
-
title: 'Upss!',
|
|
37
|
-
detail: 'No se encontró el elemento',
|
|
38
|
-
suggestion: 'Verifica que el usuario aun este activo en la plataforma',
|
|
39
|
-
error: new Error()
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (body.phone) {
|
|
44
|
-
await User.updateOne({ _id }, { 'validateKey.validatePhone.validCodePhone': false })
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
body.lastUpdate = (new Date()).getTime()
|
|
48
|
-
const result = await User.updateOne({ _id }, { $set: body })
|
|
49
|
-
|
|
50
|
-
return result
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
self.status = async (USER_ID, body) => {
|
|
54
|
-
const _id = USER_ID
|
|
55
|
-
const user = await User.findOne({ _id })
|
|
56
|
-
|
|
57
|
-
if (!user) {
|
|
58
|
-
throw {
|
|
59
|
-
code: 404,
|
|
60
|
-
title: 'Upss!',
|
|
61
|
-
detail: 'No se encontró el elemento',
|
|
62
|
-
suggestion: 'Verifica que el usuario aun este activo en la plataforma',
|
|
63
|
-
error: new Error()
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
user.status = body.status
|
|
68
|
-
user.lastUpdate = (new Date()).getTime()
|
|
69
|
-
|
|
70
|
-
const result = await user.save()
|
|
71
|
-
|
|
72
|
-
return result
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
self.updatepassword = async (body, USER_ID) => {
|
|
76
|
-
let user
|
|
77
|
-
user = User(body)
|
|
78
|
-
const _id = USER_ID
|
|
79
|
-
|
|
80
|
-
user = await User.findOne({ _id })
|
|
81
|
-
|
|
82
|
-
if (!user) {
|
|
83
|
-
throw {
|
|
84
|
-
code: 404,
|
|
85
|
-
title: 'Upss!',
|
|
86
|
-
detail: 'No se encontró el elemento',
|
|
87
|
-
suggestion: 'Verifica que el usuario aun este activo en la plataforma',
|
|
88
|
-
error: new Error()
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
user.pwd = body.pwd
|
|
93
|
-
user.lastUpdate = (new Date()).getTime()
|
|
94
|
-
|
|
95
|
-
const result = await user.save()
|
|
96
|
-
|
|
97
|
-
return result
|
|
98
|
-
}
|
|
99
|
-
|
|
1
|
+
const User = require('../models/User')
|
|
2
|
+
const self = module.exports
|
|
3
|
+
|
|
4
|
+
self.create = async (body) => {
|
|
5
|
+
let user
|
|
6
|
+
user = await User.findOne({email: body.email}).lean()
|
|
7
|
+
|
|
8
|
+
if(user){
|
|
9
|
+
throw {
|
|
10
|
+
code: 404,
|
|
11
|
+
title: 'Upss!',
|
|
12
|
+
detail: '',
|
|
13
|
+
suggestion: 'El correo ya se encuentra resgitrado',
|
|
14
|
+
error: new Error()
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
user = new User(body)
|
|
19
|
+
user.createdAt = (new Date()).getTime()
|
|
20
|
+
user.status = body?.status ? body?.status : 'Activo'
|
|
21
|
+
|
|
22
|
+
delete user.pwd
|
|
23
|
+
user.data.changePwd = false
|
|
24
|
+
await user.save()
|
|
25
|
+
|
|
26
|
+
return user
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
self.update = async (USER_ID, body) => {
|
|
30
|
+
const _id = USER_ID
|
|
31
|
+
const user = await User.findOne({ _id }).countDocuments().lean()
|
|
32
|
+
|
|
33
|
+
if (!user) {
|
|
34
|
+
throw {
|
|
35
|
+
code: 404,
|
|
36
|
+
title: 'Upss!',
|
|
37
|
+
detail: 'No se encontró el elemento',
|
|
38
|
+
suggestion: 'Verifica que el usuario aun este activo en la plataforma',
|
|
39
|
+
error: new Error()
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (body.phone) {
|
|
44
|
+
await User.updateOne({ _id }, { 'validateKey.validatePhone.validCodePhone': false })
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
body.lastUpdate = (new Date()).getTime()
|
|
48
|
+
const result = await User.updateOne({ _id }, { $set: body })
|
|
49
|
+
|
|
50
|
+
return result
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
self.status = async (USER_ID, body) => {
|
|
54
|
+
const _id = USER_ID
|
|
55
|
+
const user = await User.findOne({ _id })
|
|
56
|
+
|
|
57
|
+
if (!user) {
|
|
58
|
+
throw {
|
|
59
|
+
code: 404,
|
|
60
|
+
title: 'Upss!',
|
|
61
|
+
detail: 'No se encontró el elemento',
|
|
62
|
+
suggestion: 'Verifica que el usuario aun este activo en la plataforma',
|
|
63
|
+
error: new Error()
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
user.status = body.status
|
|
68
|
+
user.lastUpdate = (new Date()).getTime()
|
|
69
|
+
|
|
70
|
+
const result = await user.save()
|
|
71
|
+
|
|
72
|
+
return result
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
self.updatepassword = async (body, USER_ID) => {
|
|
76
|
+
let user
|
|
77
|
+
user = User(body)
|
|
78
|
+
const _id = USER_ID
|
|
79
|
+
|
|
80
|
+
user = await User.findOne({ _id })
|
|
81
|
+
|
|
82
|
+
if (!user) {
|
|
83
|
+
throw {
|
|
84
|
+
code: 404,
|
|
85
|
+
title: 'Upss!',
|
|
86
|
+
detail: 'No se encontró el elemento',
|
|
87
|
+
suggestion: 'Verifica que el usuario aun este activo en la plataforma',
|
|
88
|
+
error: new Error()
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
user.pwd = body.pwd
|
|
93
|
+
user.lastUpdate = (new Date()).getTime()
|
|
94
|
+
|
|
95
|
+
const result = await user.save()
|
|
96
|
+
|
|
97
|
+
return result
|
|
98
|
+
}
|
|
99
|
+
|