How to propagate login changes to open forms

Still getting my head wrapped around this..

I have a uilSecurityManager on a datamodule.

Two forms, both using the datamodule.

FormPolicies set on both forms.

In formMain, login as any user and see a "ShowForm2" button.

Login as admin, click on ShowForm2, the form is displayed with a DBNavigator with all buttons enabled.

Login as user, click on ShowForm2, the form is displayed with a DBNavigator with [first,prior,next,last,refresh] buttons only (set by a custom action policy).

Form2 is non-modal. I can go back to formMain and logout, then login as a different user.

If I logged in as admin, invoke form2, then logout and log back in as user, form2 still has admin  controls visible.

Is there some built-in way to propagate the login change to all child forms of formMain?

TIA.

EdB


Have you tried calling uilFormPolicy.Apply on the non-modal form2 when a new user has logged in?
After this new login, calling Apply should reapply the policies according to the new logged-in user.

Thanks Bruno.

It turns out I don't actually have to call apply...

I just set up a test policy in child form that shows a TButton if uilSecurityManager.CurrentUser is admin, and hides that button for any other user.

Works perfectly when changing login from main form.

It appears as though the child form OnCustomSecure event is triggered with 'secure' still true in the child form when the login changes.

I've even placed a button on the child form which calls that form's uilFormPolicy.Apply - the OnCustomSecure event still has previous (secure=true) value - even thought the CurrentUser is not admin.

Any suggestions?

Thanks again.

EdB

I've modified the "MultiForm" demo to show what happens in child forms.

First off,  "Secure" is ambiguous - I thought "true" meant "yes, it is secure, allow this" when apparently "true"  actually means "we need to secure this - do not allow!".

That's something that might make it to the manual...

Anyway, in playing with the modified demo project, I finally noticed that Security Settings as set in application can get messed up if I also change the settings in datamodule (ie in IDE).

So - in my previous post, I thought the policies and permissions were correct - when actually TuilFormPolicy.Apply (uFormPolicy.pas) was failing to deactivate because FSecurityManager.HasPermission(PolicyName) was returning false - the PolicyName it was in database table, but not formPolicy.

Based on the MultiForm project - this works the way I was expecting it to - no extra "apply" required.

EdB

I just installed winhelp32 in my win10 developer vm.

Opened SECURITYSYSTEMD7.HLP and found this:


TuilPermissionStorage=(psForm, psTable); 

Description

Value        Meaning
psForm        Policies are stored in the form file. (default) Policies cannot be added / removed at runtime
psTable        Policies are stored in a table (and can be changed at runtime)



I just changed my storage to psTable, and reversed my "Secure" assumption logic, and all is well.

Sorry for the extended postings.

EdB