<div dir="ltr"><div>I don't know if the solution that I implemented last night is the best one. I did the following:</div><div><br></div><div><br></div><div>//FIsEnabledBySecurity: the user can access the control? this variable is changed via another call, when user login or logout, checking the authorizations of the logged user.</div><div>//FAllowUnauthorizedShowForm: value of a property that sets if not allowed users can show the form or not.</div><div>procedure TpSCADASecureForm.SetVisible(Value: boolean); override;</div><div>begin</div><div> FIsPSCADAFormVisible:=Value;</div><div> inherited SetVisible(FIsPSCADAFormVisible and (FIsEnabledBySecurity or FAllowUnauthorizedShowForm));</div><div>end;</div><div><br></div><div>this do the job very well, showing and hiding the form across user login/logout changes, even if I call </div><div><br></div><div>TsomePSCADAFormInstance = class(TpSCADASecureForm);</div><div>somePSCADAFormInstance:TsomePSCADAFormInstance;</div><div><br></div><div>somePSCADAFormInstance.Visible := true;</div><div>somePSCADAFormInstance.Show;</div><div><br></div><div>but when I call </div><div><br></div><div>somePSCADAFormInstance.ShowModal;</div><div><br></div><div>I got a Exception that says that somePSCADAFormInstance is not enabled (that is true, because I have a access try of a not allowed user), but this exception is not the real cause of the problem, that is access of a not allowed user or a not logged user.</div><div><br></div><div>My solution at this point is override the ShowModal:</div><div><br></div><div>//FSecurityCode is a property with a string that describes the permission that you will give or not for each user</div><div>//GetPascalSCADAControlSecurityManager: class instance that manages the control interaction with users and their permissions, 44</div><div>//Each control that supports the interface ISecureControlInterface, should register/unregister with this manager, to be notified about user changes/permission changes. </div><div>function TpSCADASecureForm.ShowModal: Integer; override;</div><div>begin</div><div> if GetPascalSCADAControlSecurityManager.CanAccess(FSecurityCode)=false then</div><div> raise ESecuritySystemAccessDenied.Create(FSecurityCode);</div><div><br></div><div> Result:=inherited ShowModal;</div><div>end; </div><div><br></div><div><br></div><div>What is your opinion?</div><div class="gmail_extra">
</div></div>