I have still a problem with using the security! Has someone an suggestion where the problem can be or what mistakes I made? The security settings are not right for the forms I set it.
I am using enhanced security with an login-modul and an authenticator-modul.
On pressing login button:
function onActionLogin(event) {
var loginResult = security.authenticate('HadesAuthenticator', 'login', [username, password]);
if (!loginResult) {
elements.lblLoginFaild.visible = true;
}
}
In the authenticator-modul I am logging in the user:
function login(username, password) {
if (!(username && password)) {
application.output('Unexpected credentials received', LOGGINGLEVEL.DEBUG);
return false;
}
var queryUser = "SELECT DISTINCT p.id, p.name, p.first_name, g.id, g.name\
FROM\
persons p\
INNER JOIN persons_groups pg\
ON pg.person_id = p.id\
INNER JOIN groups g\
ON pg.group_id = g.id\
WHERE\
p.usr = '" + username + "'\
AND p.pwd= '" + password + "'"
var datasetUser = databaseManager.getDataSetByQuery('hades', queryUser, null, -1);
if (datasetUser != null) {
application.output(datasetUser.getValue(1,2) + ' ' + datasetUser.getValue(1,3) + ' ' + datasetUser.getValue(1,1) + ' ' + datasetUser.getColumnAsArray(5));
/*security.createUser(username,password,datasetUser.getValue(1,1));
security.addUserToGroup(datasetUser.getValue(1,1),datasetUser.getValue(1,5));*/
var ok = security.login(datasetUser.getValue(1,2) + ' ' + datasetUser.getValue(1,3), datasetUser.getValue(1,1), datasetUser.getColumnAsArray(5));
return ok;
}
return false;
}
After the login was successful the onOpen method of the solution is triggerd and I initialize the security:
function secInit() {
var queryRights = "SELECT DISTINCT r.form_name, r.form_element, r.right_value\
FROM\
persons_groups pg\
INNER JOIN rights r\
ON r.group_id = pg.group_id\
WHERE\
pg.person_id = " + security.getUserUID(); //security.getUserGroups().getValue(1,2)
var datasetRights = databaseManager.getDataSetByQuery('hades', queryRights, null, -1);
globals.prcDatasetSecurity = databaseManager.createEmptyDataSet(0, ['uuid', 'flags']);
application.output(queryRights);
for (var i = 1; i <= datasetRights.getMaxRowIndex(); i++) {
forms.PrcSecurity.setSecurityToSubForms(datasetRights.getValue(i, 1),datasetRights.getValue(i, 3))
}
application.output(globals.prcDatasetSecurity);
security.setSecuritySettings(globals.prcDatasetSecurity);
}
The Function PrcSecurity.setSecurityToSubForms returns a dataset:
row_1[caae7557-a4dc-4769-b764-9975dd3e3f09, 1]
row_2[0099f4a4-e9d5-4b91-b110-f03e87bdc6e0, 1]
row_3[4738f572-780c-43c4-bc1e-5d5ec7ffc98f, 1]
row_4[31870021-0c5d-4fb7-b73b-c1e2b0614d4f, 1]
row_5[338f5177-911c-4487-85c7-39fcce890dc5, 1]
row_6[b8e82d64-eaf9-4bfc-b955-f63cf4f8811d, 1]
row_7[58ed7634-142f-4e70-83ee-1579ec9dfd62, 1]
row_8[b2e41ac5-2ab9-49ca-ba27-f2b53d5fde9c, 1]
This dataset is given to setSecuritySettings and the uuids are for Forms or for Elements. But both dose not work! But the Forms should only be viewable but they are editable. And I don’t understand why.
Regards, Stef