Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions constants/role.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,27 +151,26 @@ function createAllSingularRoles() {
const allRoutes = Constants.Routes.allRoutes;
let roles = [];

// i is unique integer so that objectId is constant
var i = 1000000;
for (let routeGroupKey in allRoutes) {
if (!allRoutes.hasOwnProperty(routeGroupKey)) {
if (!Object.prototype.hasOwnProperty.call(allRoutes, routeGroupKey)) {
continue;
}

const routeGroup = allRoutes[routeGroupKey];
for (let routeKey in routeGroup) {
if (!routeGroup.hasOwnProperty(routeKey)) {
// Iterating through the attributes in the routeGroup object
if (!Object.prototype.hasOwnProperty.call(routeGroup, routeKey)) {
// Avoid all prototype attributes
continue;
}

let role = {
_id: mongoose.Types.ObjectId(i),
_id: routeGroup[routeKey]._id,
name: routeKey + routeGroupKey,
routes: routeGroup[routeKey]
};
let roleName = role.name;
roles[roleName] = role;
i -= 1;
}
}

Expand All @@ -197,7 +196,7 @@ function createAllRoles() {

const singularRoles = createAllSingularRoles();
for (let role in singularRoles) {
if (!singularRoles.hasOwnProperty(role)) {
if (!Object.prototype.hasOwnProperty.call(singularRoles, role)) {
continue;
}
allRolesObject[role] = singularRoles[role];
Expand Down
Loading