Skip to content
Snippets Groups Projects
Commit 7e18d672 authored by Simon Leipold's avatar Simon Leipold
Browse files

Permission bug fix: function insertPermission now prevents NULL values from...

Permission bug fix: function insertPermission now prevents NULL values from being stored as conditional strings
parent 540981e3
No related branches found
No related tags found
No related merge requests found
......@@ -34,13 +34,13 @@ if (fullPermissions == 1) {
// === ENTITY === //
var entitySetId = PermissionUtil.insertSet("", entityName, roleName, "", ACCESSLEVEL_ENTITY); // entity level set
var entityPermId = PermissionUtil.insertPermission(entitySetId, "", "1", null); // entity level permission
var entityPermId = PermissionUtil.insertPermission(entitySetId, null, "1", null); // entity level permission
PermissionUtil.insertAction(entityPermId, ACTION_VIEW, null); // action view
PermissionUtil.insertAction(entityPermId, ACTION_CREATE, null); // action create
// === RECORD === //
var recordSetId = PermissionUtil.insertSet(entitySetId, entityName, roleName, "", ACCESSLEVEL_RECORD); // record level set
var recordPermId = PermissionUtil.insertPermission(recordSetId, "", "1", null); // record level permission
var recordPermId = PermissionUtil.insertPermission(recordSetId, null, "1", null); // record level permission
PermissionUtil.insertAction(recordPermId, ACTION_READ, null); // read
PermissionUtil.insertAction(recordPermId, ACTION_UPDATE, null); // update
PermissionUtil.insertAction(recordPermId, ACTION_DELETE, null); // delete
......
......@@ -239,13 +239,13 @@ function PermissionUtil () {}
}
/**
* get the entity for a specific permissionset.
* Get the entity for a specific permissionset.
*
* @param {String} pSetId the id of the permission set
*
* @return {String} the entity name or an empty string if not found
*/
PermissionUtil._getEntity = function(pSetId) {
PermissionUtil.getEntity = function(pSetId) {
return newSelect("ENTITY_ID", alias)
.from("ASYS_PERMISSIONSET")
.whereIfSet("ASYS_PERMISSIONSET.ASYS_PERMISSIONSETID", pSetId)
......@@ -260,7 +260,7 @@ function PermissionUtil () {}
* @result {String} returns id of default permission of given set. Never 'null', empty string if there is no result.
*/
PermissionUtil.getPermissionWithoutCond = function(pSetId) {
var emptyCond = PermissionUtil.getEmptyCondString(PermissionUtil._getEntity(pSetId));
var emptyCond = PermissionUtil.getEmptyCondString(PermissionUtil.getEntity(pSetId));
return newSelect("ASYS_PERMISSIONID", alias)
.from("ASYS_PERMISSION")
......@@ -280,7 +280,7 @@ function PermissionUtil () {}
* @result {String[]} returns the ids of permissions with conditions of a given permission set. The result can never be null.
*/
PermissionUtil.getPermissionWithCond = function(pSetId) {
var emptyCond = PermissionUtil.getEmptyCondString(PermissionUtil._getEntity(pSetId));
var emptyCond = PermissionUtil.getEmptyCondString(PermissionUtil.getEntity(pSetId));
return newSelect("ASYS_PERMISSIONID", alias)
.from("ASYS_PERMISSION")
......@@ -446,7 +446,7 @@ function PermissionUtil () {}
*
* @param {String} pParentSetId parent permission set, mandatory
*
* @param {String} pCond condition of the permission, empty if no condition
* @param {String} pCond condition of the permission, null if no condition
*
* @param {String} pCondType condition Type of the permission, should always be 1
*
......@@ -463,12 +463,15 @@ function PermissionUtil () {}
"COND"
];
var permId;
var cond = (pCond == null ? PermissionUtil.getEmptyCondString(PermissionUtil.getEntity(pParentSetId)) : pCond);
if (pPermId != null && pPermId != "" && pPermId != undefined) {
permId = pPermId;
} else {
permId = util.getNewUUID();
}
var vals = [pParentSetId, permId, pCondType, pCond];
var vals = [pParentSetId, permId, pCondType, cond];
db.insertData(table, cols, null, vals, alias);
return permId;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment