Normally the value of this column is 0. After the user is given (or loses) access to an application or gets a new permission for an application, this column gets set to 1 to indicate that the users' perms and roles has changed and needs to be reloaded.
Every time that the user accesses an application, a globally shared function called verifyUserSession() is called in the before page event to make sure that the user is allowed to have access to the application. This application also checks to see if ReloadPermissionsAndRoles=1. If it is, it dynamically reloads the permission and what applications the user has access to by re-initiating the login process because the login is where the users' access and permissions are initialized. I do it this way because without re-initiating the login process, the user would have to log off and then log on again to make the changes in access go into effect and I don't want to have to have them do this.
In the logon service, this is how the users' access gets initialized
Code: Select all
// Get all the menus that this user is authorized for based on their user ID
tables.GENERATE_USER_MENU.UserID.value=tables.USERS.USERID.value;
tables.GENERATE_USER_MENU.fetchTable();
if ( tables.GENERATE_USER_MENU.rowCount > 0 ) {
var allMenuRows=tables.GENERATE_USER_MENU;
var menuRows=allMenuRows.getRows();
while (menuRows.next()) {
// Add the menu name to the custom roles so it can be used to determine whether a user has access to that menu
tables.CUSTOMROLES.insertRow();
tables.CUSTOMROLES.ROLEID.value=allMenuRows.MENUNAME.value;
tables.CUSTOMROLES.updateTable();
}
}
// Get all of the users' permissions based on their user ID
tables.Permissions.UserID.value=tables.USERS.USERID.value;
tables.Permissions.fetchTable();
var allPermissions=tables.Permissions;
var allPermissionsRows=allPermissions.getRows();
while (allPermissionsRows.next()) {
tables.CREDENTIALS.insertRow();
tables.CREDENTIALS.ID.value=allPermissions.PermissionName.value.toUpperCase(); // Instead of fixing all places that reference the check to see if the user has the permission, I make this upper case so its always consistent
tables.CREDENTIALS.VALUE.value=(allPermissions.HasAccess.value==true ? 1 : 0);
tables.CREDENTIALS.updateTable();
}
// Invoke the LOGON service
system.securityManager.logon([["",columnData.Username],["",columnData.Password]]);
This usually works except that lately I've had an issue lately where about every 1 in 10 times that I do this, the server locks up and stops responding and I have to restart the server.
I think that the User database is getting overwhelmed and cant accept new logins after a while.
Is there a better way to re-initiate the login process ?