aloux-iam 0.0.114 → 0.0.115
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/functions.js +86 -86
- package/lib/controllers/history.js +97 -97
- package/lib/controllers/label.js +82 -0
- package/lib/controllers/log.js +268 -0
- 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 -848
- package/lib/middleware.js +146 -146
- package/lib/models/Business.js +14 -14
- package/lib/models/Functions.js +13 -13
- package/lib/models/History.js +15 -15
- package/lib/models/Label.js +13 -0
- package/lib/models/Log.js +11 -0
- package/lib/models/Menu.js +17 -17
- package/lib/models/Permission.js +16 -16
- package/lib/models/User.js +115 -115
- package/lib/models/UserProvisional.js +10 -10
- package/lib/router.js +104 -82
- package/lib/services/auth.js +956 -956
- 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/middleware.js
CHANGED
|
@@ -1,146 +1,146 @@
|
|
|
1
|
-
const jwt = require("jsonwebtoken");
|
|
2
|
-
const User = require("./models/User");
|
|
3
|
-
const Permission = require("./models/Permission");
|
|
4
|
-
const historyController = require("./controllers/history");
|
|
5
|
-
|
|
6
|
-
const getAccess = (user, resource) => {
|
|
7
|
-
for (let i in user._functions) {
|
|
8
|
-
for (let j in user._functions[i]._permissions) {
|
|
9
|
-
if (user._functions[i]._permissions[j].status === "Activo") {
|
|
10
|
-
const permissionBack =
|
|
11
|
-
user._functions[i]._permissions[j].method +
|
|
12
|
-
" " +
|
|
13
|
-
user._functions[i]._permissions[j].endpoint;
|
|
14
|
-
if (permissionBack === resource.method + " " + resource.endpoint) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
return false;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const auth = async (req, res, next) => {
|
|
24
|
-
try {
|
|
25
|
-
let newHistory;
|
|
26
|
-
if (process.env.HISTORY === "true") {
|
|
27
|
-
const endpoints = process.env.HISTORY_ENDPOINTS.split(",");
|
|
28
|
-
const urlToCheck = req.route.path;
|
|
29
|
-
if (endpoints.includes(urlToCheck)) {
|
|
30
|
-
newHistory = await historyController.create(req);
|
|
31
|
-
req.history = newHistory._id.toString();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
let token =
|
|
36
|
-
req.header("Authorization") || (req.cookies && req.cookies.token);
|
|
37
|
-
|
|
38
|
-
if (!token) {
|
|
39
|
-
throw {
|
|
40
|
-
code: 401,
|
|
41
|
-
title: "Error de autenticación",
|
|
42
|
-
detail: "Endpoint requiere token",
|
|
43
|
-
suggestion: "Vuelve a iniciar sesion",
|
|
44
|
-
error: new Error(),
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
token = token.replace("Bearer ", "");
|
|
49
|
-
|
|
50
|
-
const data = jwt.verify(token, process.env.AUTH_SECRET);
|
|
51
|
-
const user = await User.findOne(
|
|
52
|
-
{ _id: data._id, "tokens.token": token, status: "Activo" },
|
|
53
|
-
{ tokens: 0, pwd: 0 }
|
|
54
|
-
)
|
|
55
|
-
.populate({ path: "_functions", populate: [{ path: "_permissions" }] })
|
|
56
|
-
.lean();
|
|
57
|
-
|
|
58
|
-
if (!user) {
|
|
59
|
-
throw {
|
|
60
|
-
code: 401,
|
|
61
|
-
title: "Error de autenticación",
|
|
62
|
-
detail: "No se encontró el usuario",
|
|
63
|
-
suggestion: "Vuelve a iniciar sesion",
|
|
64
|
-
error: new Error(),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//Time session
|
|
69
|
-
if (process.env.SESSION_INTERRUPTOR === "true") {
|
|
70
|
-
const userTokens = await User.findOne(
|
|
71
|
-
{ _id: user._id, status: "Activo" },
|
|
72
|
-
{ tokens: 1 }
|
|
73
|
-
).lean();
|
|
74
|
-
const tokenObject = userTokens.tokens.find((t) => t.token === token);
|
|
75
|
-
if (tokenObject.dateEnd <= Date.now()) {
|
|
76
|
-
await User.updateOne(
|
|
77
|
-
{ _id: userTokens._id },
|
|
78
|
-
{
|
|
79
|
-
$pull: {
|
|
80
|
-
tokens: { token: tokenObject.token }, // Condición para eliminar el token específico
|
|
81
|
-
},
|
|
82
|
-
}
|
|
83
|
-
);
|
|
84
|
-
throw {
|
|
85
|
-
code: 401,
|
|
86
|
-
title: "La sesión expiró",
|
|
87
|
-
detail: "Has llegado al tiempo límite de tu sesión",
|
|
88
|
-
suggestion: "Se eliminó la sesión vencida",
|
|
89
|
-
error: new Error(),
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const resource = await Permission.findOne({
|
|
95
|
-
method: req.originalMethod,
|
|
96
|
-
endpoint: req.route.path,
|
|
97
|
-
}).lean();
|
|
98
|
-
if (!resource) {
|
|
99
|
-
throw {
|
|
100
|
-
code: 403,
|
|
101
|
-
title: "Error de recurso",
|
|
102
|
-
detail:
|
|
103
|
-
"No se encontro dado de alta el privilegio del endpoint: [" +
|
|
104
|
-
req.route.path +
|
|
105
|
-
"]",
|
|
106
|
-
suggestion: "Contacta con el administrador",
|
|
107
|
-
error: new Error(),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (resource.auth && !resource.default) {
|
|
112
|
-
const access = getAccess(user, resource);
|
|
113
|
-
if (!access) {
|
|
114
|
-
throw {
|
|
115
|
-
code: 403,
|
|
116
|
-
title: "Error de permisos",
|
|
117
|
-
detail:
|
|
118
|
-
"No cuentas con permisos para el recurso [" +
|
|
119
|
-
resource.api +
|
|
120
|
-
"] que: " +
|
|
121
|
-
(resource ? resource.description : "Recurso indefinido"),
|
|
122
|
-
suggestion: "Contacta con el administrador",
|
|
123
|
-
error: new Error(),
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
req.user = user;
|
|
129
|
-
req.token = token;
|
|
130
|
-
req.permission = resource ? resource.description : "Recurso indefinido";
|
|
131
|
-
next();
|
|
132
|
-
} catch (error) {
|
|
133
|
-
let obj = error;
|
|
134
|
-
if (!error.code) {
|
|
135
|
-
obj = {
|
|
136
|
-
code: 401,
|
|
137
|
-
title: "Error de autenticación",
|
|
138
|
-
detail: error.message,
|
|
139
|
-
suggestion: "Vuelve a iniciar sesion",
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
res.status(obj.code).send(obj);
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
module.exports = auth;
|
|
1
|
+
const jwt = require("jsonwebtoken");
|
|
2
|
+
const User = require("./models/User");
|
|
3
|
+
const Permission = require("./models/Permission");
|
|
4
|
+
const historyController = require("./controllers/history");
|
|
5
|
+
|
|
6
|
+
const getAccess = (user, resource) => {
|
|
7
|
+
for (let i in user._functions) {
|
|
8
|
+
for (let j in user._functions[i]._permissions) {
|
|
9
|
+
if (user._functions[i]._permissions[j].status === "Activo") {
|
|
10
|
+
const permissionBack =
|
|
11
|
+
user._functions[i]._permissions[j].method +
|
|
12
|
+
" " +
|
|
13
|
+
user._functions[i]._permissions[j].endpoint;
|
|
14
|
+
if (permissionBack === resource.method + " " + resource.endpoint) {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const auth = async (req, res, next) => {
|
|
24
|
+
try {
|
|
25
|
+
let newHistory;
|
|
26
|
+
if (process.env.HISTORY === "true") {
|
|
27
|
+
const endpoints = process.env.HISTORY_ENDPOINTS.split(",");
|
|
28
|
+
const urlToCheck = req.route.path;
|
|
29
|
+
if (endpoints.includes(urlToCheck)) {
|
|
30
|
+
newHistory = await historyController.create(req);
|
|
31
|
+
req.history = newHistory._id.toString();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let token =
|
|
36
|
+
req.header("Authorization") || (req.cookies && req.cookies.token);
|
|
37
|
+
|
|
38
|
+
if (!token) {
|
|
39
|
+
throw {
|
|
40
|
+
code: 401,
|
|
41
|
+
title: "Error de autenticación",
|
|
42
|
+
detail: "Endpoint requiere token",
|
|
43
|
+
suggestion: "Vuelve a iniciar sesion",
|
|
44
|
+
error: new Error(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
token = token.replace("Bearer ", "");
|
|
49
|
+
|
|
50
|
+
const data = jwt.verify(token, process.env.AUTH_SECRET);
|
|
51
|
+
const user = await User.findOne(
|
|
52
|
+
{ _id: data._id, "tokens.token": token, status: "Activo" },
|
|
53
|
+
{ tokens: 0, pwd: 0 }
|
|
54
|
+
)
|
|
55
|
+
.populate({ path: "_functions", populate: [{ path: "_permissions" }] })
|
|
56
|
+
.lean();
|
|
57
|
+
|
|
58
|
+
if (!user) {
|
|
59
|
+
throw {
|
|
60
|
+
code: 401,
|
|
61
|
+
title: "Error de autenticación",
|
|
62
|
+
detail: "No se encontró el usuario",
|
|
63
|
+
suggestion: "Vuelve a iniciar sesion",
|
|
64
|
+
error: new Error(),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
//Time session
|
|
69
|
+
if (process.env.SESSION_INTERRUPTOR === "true") {
|
|
70
|
+
const userTokens = await User.findOne(
|
|
71
|
+
{ _id: user._id, status: "Activo" },
|
|
72
|
+
{ tokens: 1 }
|
|
73
|
+
).lean();
|
|
74
|
+
const tokenObject = userTokens.tokens.find((t) => t.token === token);
|
|
75
|
+
if (tokenObject.dateEnd <= Date.now()) {
|
|
76
|
+
await User.updateOne(
|
|
77
|
+
{ _id: userTokens._id },
|
|
78
|
+
{
|
|
79
|
+
$pull: {
|
|
80
|
+
tokens: { token: tokenObject.token }, // Condición para eliminar el token específico
|
|
81
|
+
},
|
|
82
|
+
}
|
|
83
|
+
);
|
|
84
|
+
throw {
|
|
85
|
+
code: 401,
|
|
86
|
+
title: "La sesión expiró",
|
|
87
|
+
detail: "Has llegado al tiempo límite de tu sesión",
|
|
88
|
+
suggestion: "Se eliminó la sesión vencida",
|
|
89
|
+
error: new Error(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const resource = await Permission.findOne({
|
|
95
|
+
method: req.originalMethod,
|
|
96
|
+
endpoint: req.route.path,
|
|
97
|
+
}).lean();
|
|
98
|
+
if (!resource) {
|
|
99
|
+
throw {
|
|
100
|
+
code: 403,
|
|
101
|
+
title: "Error de recurso",
|
|
102
|
+
detail:
|
|
103
|
+
"No se encontro dado de alta el privilegio del endpoint: [" +
|
|
104
|
+
req.route.path +
|
|
105
|
+
"]",
|
|
106
|
+
suggestion: "Contacta con el administrador",
|
|
107
|
+
error: new Error(),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (resource.auth && !resource.default) {
|
|
112
|
+
const access = getAccess(user, resource);
|
|
113
|
+
if (!access) {
|
|
114
|
+
throw {
|
|
115
|
+
code: 403,
|
|
116
|
+
title: "Error de permisos",
|
|
117
|
+
detail:
|
|
118
|
+
"No cuentas con permisos para el recurso [" +
|
|
119
|
+
resource.api +
|
|
120
|
+
"] que: " +
|
|
121
|
+
(resource ? resource.description : "Recurso indefinido"),
|
|
122
|
+
suggestion: "Contacta con el administrador",
|
|
123
|
+
error: new Error(),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
req.user = user;
|
|
129
|
+
req.token = token;
|
|
130
|
+
req.permission = resource ? resource.description : "Recurso indefinido";
|
|
131
|
+
next();
|
|
132
|
+
} catch (error) {
|
|
133
|
+
let obj = error;
|
|
134
|
+
if (!error.code) {
|
|
135
|
+
obj = {
|
|
136
|
+
code: 401,
|
|
137
|
+
title: "Error de autenticación",
|
|
138
|
+
detail: error.message,
|
|
139
|
+
suggestion: "Vuelve a iniciar sesion",
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
res.status(obj.code).send(obj);
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
module.exports = auth;
|
package/lib/models/Business.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const businessSchema = mongoose.Schema({
|
|
4
|
-
name: { type: String, required: true, trim: true, maxLength: 200 },
|
|
5
|
-
imgUrl: { type: String, required: false, trim: true, maxLength: 500 },
|
|
6
|
-
data: { type: Object, required: false },
|
|
7
|
-
|
|
8
|
-
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
9
|
-
createdAt: { type: Number },
|
|
10
|
-
lastUpdate: { type: Number },
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
const Business = mongoose.model("Business", businessSchema);
|
|
14
|
-
module.exports = Business;
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const businessSchema = mongoose.Schema({
|
|
4
|
+
name: { type: String, required: true, trim: true, maxLength: 200 },
|
|
5
|
+
imgUrl: { type: String, required: false, trim: true, maxLength: 500 },
|
|
6
|
+
data: { type: Object, required: false },
|
|
7
|
+
|
|
8
|
+
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
9
|
+
createdAt: { type: Number },
|
|
10
|
+
lastUpdate: { type: Number },
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const Business = mongoose.model("Business", businessSchema);
|
|
14
|
+
module.exports = Business;
|
package/lib/models/Functions.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const mongoose = require('mongoose')
|
|
2
|
-
|
|
3
|
-
const functionsSchema = mongoose.Schema({
|
|
4
|
-
name: { type: String, required: true, trim: true, unique: true },
|
|
5
|
-
description: { type: String, trim: true },
|
|
6
|
-
_permissions: [ { type: mongoose.Schema.Types.ObjectId, required: true, ref: 'Permission' } ],
|
|
7
|
-
_menus: [ { type: mongoose.Schema.Types.ObjectId, required: true, ref: 'Menu' } ],
|
|
8
|
-
status: { type: String, required: true, enum: ['Activo','Inactivo'] },
|
|
9
|
-
createdAt: { type: Number },
|
|
10
|
-
lastUpdate: { type: Number }
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
const Functions = mongoose.model("Functions", functionsSchema)
|
|
1
|
+
const mongoose = require('mongoose')
|
|
2
|
+
|
|
3
|
+
const functionsSchema = mongoose.Schema({
|
|
4
|
+
name: { type: String, required: true, trim: true, unique: true },
|
|
5
|
+
description: { type: String, trim: true },
|
|
6
|
+
_permissions: [ { type: mongoose.Schema.Types.ObjectId, required: true, ref: 'Permission' } ],
|
|
7
|
+
_menus: [ { type: mongoose.Schema.Types.ObjectId, required: true, ref: 'Menu' } ],
|
|
8
|
+
status: { type: String, required: true, enum: ['Activo','Inactivo'] },
|
|
9
|
+
createdAt: { type: Number },
|
|
10
|
+
lastUpdate: { type: Number }
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
const Functions = mongoose.model("Functions", functionsSchema)
|
|
14
14
|
module.exports = Functions
|
package/lib/models/History.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
3
|
-
|
|
4
|
-
const historySchema = mongoose.Schema({
|
|
5
|
-
method: { type: String, default: false },
|
|
6
|
-
path: { type: String },
|
|
7
|
-
permission: { type: String },
|
|
8
|
-
payload: { type: Object, default: {} }, // Guarda cualquier estructura JSON
|
|
9
|
-
response: { type: Object, default: {} }, // Guarda cualquier estructura JSON
|
|
10
|
-
_createdBy: { type: ObjectId, required: false, ref: "User" },
|
|
11
|
-
createdAt: { type: Number, required: true },
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
const History = mongoose.model("History", historySchema);
|
|
15
|
-
module.exports = History;
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
3
|
+
|
|
4
|
+
const historySchema = mongoose.Schema({
|
|
5
|
+
method: { type: String, default: false },
|
|
6
|
+
path: { type: String },
|
|
7
|
+
permission: { type: String },
|
|
8
|
+
payload: { type: Object, default: {} }, // Guarda cualquier estructura JSON
|
|
9
|
+
response: { type: Object, default: {} }, // Guarda cualquier estructura JSON
|
|
10
|
+
_createdBy: { type: ObjectId, required: false, ref: "User" },
|
|
11
|
+
createdAt: { type: Number, required: true },
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const History = mongoose.model("History", historySchema);
|
|
15
|
+
module.exports = History;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const menuSchema = mongoose.Schema({
|
|
4
|
+
label: { type: String, required: true, trim: true },
|
|
5
|
+
description: { type: String, required: false, trim: true },
|
|
6
|
+
|
|
7
|
+
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
8
|
+
createdAt: { type: Number },
|
|
9
|
+
lastUpdate: { type: Number },
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const Menu = mongoose.model("Label", menuSchema);
|
|
13
|
+
module.exports = Menu;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
const ObjectId = mongoose.Schema.Types.ObjectId;
|
|
3
|
+
|
|
4
|
+
const menuSchema = mongoose.Schema({
|
|
5
|
+
_label: { type: ObjectId, required: true, ref: "Label" },
|
|
6
|
+
_user: { type: ObjectId, required: true, ref: "User" },
|
|
7
|
+
createdAt: { type: Number },
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const Menu = mongoose.model("Log", menuSchema);
|
|
11
|
+
module.exports = Menu;
|
package/lib/models/Menu.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const menuSchema = mongoose.Schema({
|
|
4
|
-
label: { type: String, required: true, trim: true },
|
|
5
|
-
description: { type: String, required: false, trim: true },
|
|
6
|
-
path: { type: String, required: true, trim: true },
|
|
7
|
-
icon: { type: String, required: false, trim: true },
|
|
8
|
-
index: { type: Number },
|
|
9
|
-
_menu: { type: mongoose.Schema.Types.ObjectId, ref: "Menu" },
|
|
10
|
-
|
|
11
|
-
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
12
|
-
createdAt: { type: Number },
|
|
13
|
-
lastUpdate: { type: Number },
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const Menu = mongoose.model("Menu", menuSchema);
|
|
17
|
-
module.exports = Menu;
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const menuSchema = mongoose.Schema({
|
|
4
|
+
label: { type: String, required: true, trim: true },
|
|
5
|
+
description: { type: String, required: false, trim: true },
|
|
6
|
+
path: { type: String, required: true, trim: true },
|
|
7
|
+
icon: { type: String, required: false, trim: true },
|
|
8
|
+
index: { type: Number },
|
|
9
|
+
_menu: { type: mongoose.Schema.Types.ObjectId, ref: "Menu" },
|
|
10
|
+
|
|
11
|
+
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
12
|
+
createdAt: { type: Number },
|
|
13
|
+
lastUpdate: { type: Number },
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const Menu = mongoose.model("Menu", menuSchema);
|
|
17
|
+
module.exports = Menu;
|
package/lib/models/Permission.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const mongoose = require("mongoose");
|
|
2
|
-
|
|
3
|
-
const permissionSchema = mongoose.Schema({
|
|
4
|
-
description: { type: String, required: true, trim: true },
|
|
5
|
-
method: { type: String, required: true, unique: true },
|
|
6
|
-
api: { type: String, required: true },
|
|
7
|
-
endpoint: { type: String, required: true },
|
|
8
|
-
auth: { type: Number, required: true, default: 1 },
|
|
9
|
-
default: { type: Boolean },
|
|
10
|
-
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
11
|
-
createdAt: { type: Number },
|
|
12
|
-
lastUpdate: { type: Number },
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const Permission = mongoose.model("Permission", permissionSchema);
|
|
16
|
-
module.exports = Permission;
|
|
1
|
+
const mongoose = require("mongoose");
|
|
2
|
+
|
|
3
|
+
const permissionSchema = mongoose.Schema({
|
|
4
|
+
description: { type: String, required: true, trim: true },
|
|
5
|
+
method: { type: String, required: true, unique: true },
|
|
6
|
+
api: { type: String, required: true },
|
|
7
|
+
endpoint: { type: String, required: true },
|
|
8
|
+
auth: { type: Number, required: true, default: 1 },
|
|
9
|
+
default: { type: Boolean },
|
|
10
|
+
status: { type: String, required: true, enum: ["Activo", "Inactivo"] },
|
|
11
|
+
createdAt: { type: Number },
|
|
12
|
+
lastUpdate: { type: Number },
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const Permission = mongoose.model("Permission", permissionSchema);
|
|
16
|
+
module.exports = Permission;
|